fix process refcount so that process structure is still valid when final release() is called in schedule()

This commit is contained in:
Balazs Gerofi bgerofi@riken.jp
2014-04-24 17:09:14 +09:00
parent 0e348e6295
commit c15c2a2024
2 changed files with 6 additions and 2 deletions

View File

@ -130,7 +130,7 @@ struct process *create_process(unsigned long user_pc)
return NULL;
memset(proc, 0, sizeof(struct process));
ihk_atomic_set(&proc->refcount, 1);
ihk_atomic_set(&proc->refcount, 2);
proc->sighandler = kmalloc(sizeof(struct sig_handler), IHK_MC_AP_NOWAIT);
if(!proc->sighandler){
@ -194,7 +194,7 @@ struct process *clone_process(struct process *org, unsigned long pc,
}
memset(proc, 0, sizeof(struct process));
ihk_atomic_set(&proc->refcount, 1);
ihk_atomic_set(&proc->refcount, 2);
/* NOTE: sp is the user mode stack! */
ihk_mc_init_user_process(&proc->ctx, &proc->uctx,

View File

@ -404,7 +404,10 @@ terminate(int rc, int sig, ihk_mc_user_context_t *ctx)
}
release_fork_tree_node(ftn);
proc->status = PS_EXITED;
release_process(proc);
schedule();
}
@ -1743,6 +1746,7 @@ SYSCALL_DECLARE(exit)
proc->status = PS_ZOMBIE;
release_fork_tree_node(proc->ftn);
release_process(proc);
schedule();