diff options
| author | Hanjie Wu <hanjiew@andrew.cmu.edu> | 2023-04-28 19:37:31 -0400 |
|---|---|---|
| committer | Hanjie Wu <hanjiew@andrew.cmu.edu> | 2023-04-28 19:37:31 -0400 |
| commit | ff90341c64565ac7d8034d2f8cf460532a5b51fd (patch) | |
| tree | 7056c18c075aa5b6a4bdef124342866973506eee /kern/sched.c | |
| parent | 09cce089128de5f265ee6d4e68e196f85537ccc7 (diff) | |
fix
Diffstat (limited to 'kern/sched.c')
| -rw-r--r-- | kern/sched.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kern/sched.c b/kern/sched.c index 7764c26..f797409 100644 --- a/kern/sched.c +++ b/kern/sched.c @@ -647,15 +647,21 @@ void kill_current() { if (p->refcount == 1) { mutex_lock(&p->wait_lock); /* reclaim dead childs */ + queue_t* dead_childs = NULL; while (p->dead_childs != NULL) { queue_t* node = p->dead_childs; queue_detach(&p->dead_childs, node); + queue_insert_tail(&dead_childs, node); + p->nchilds--; + } + mutex_unlock(&p->wait_lock); + while (dead_childs != NULL) { + queue_t* node = dead_childs; + queue_detach(&dead_childs, node); process_t* child_process = queue_data(node, process_t, sible_link); sfree(child_process, sizeof(process_t)); - p->nchilds--; } - mutex_unlock(&p->wait_lock); const char* init_args[] = {INIT_NAME}; thread_t* new_init = create_process(current->rb_node.key, INIT_NAME, 1, init_args); |
