Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_exit.c
Show First 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
sys_exit(struct thread *td, struct exit_args *uap) | sys_exit(struct thread *td, struct exit_args *uap) | ||||
{ | { | ||||
exit1(td, uap->rval, 0); | exit1(td, uap->rval, 0); | ||||
__unreachable(); | __unreachable(); | ||||
} | } | ||||
void | |||||
proc_set_p2_wexit(struct proc *p) | |||||
{ | |||||
PROC_LOCK_ASSERT(p, MA_OWNED); | |||||
p->p_flag2 |= P2_WEXIT; | |||||
while (p->p_singlethr > 0) | |||||
msleep(&p->p_singlethr, &p->p_mtx, PWAIT | PCATCH, "exit1t", 0); | |||||
markj: Is PCATCH correct here? Upon receiving a signal we'll spin in the loop until `p_singlethr` goes… | |||||
Done Inline ActionsWe need to be able to suspend there. Would we have something PSUSP instead of PCATCH, it be better indeed. kib: We need to be able to suspend there. Would we have something PSUSP instead of PCATCH, it be… | |||||
Done Inline ActionsI surprised myself by being able to generate an another approach. If P2_WEXIT is set, then there is no sense trying to deliver a signal, since it cannot reach userspace. Then issignal() should start ignoring queued signals after P2_WEXIT. Not sure about other side effects, but lets try? kib: I surprised myself by being able to generate an another approach. If P2_WEXIT is set, then… | |||||
} | |||||
/* | /* | ||||
* Exit: deallocate address space and other resources, change proc state to | * Exit: deallocate address space and other resources, change proc state to | ||||
* zombie, and unlink proc from allproc and parent's lists. Save exit status | * zombie, and unlink proc from allproc and parent's lists. Save exit status | ||||
* and rusage for wait(). Check for child processes and orphan them. | * and rusage for wait(). Check for child processes and orphan them. | ||||
*/ | */ | ||||
void | void | ||||
exit1(struct thread *td, int rval, int signo) | exit1(struct thread *td, int rval, int signo) | ||||
{ | { | ||||
Show All 22 Lines | exit1(struct thread *td, int rval, int signo) | ||||
* Deref SU mp, since the thread does not return to userspace. | * Deref SU mp, since the thread does not return to userspace. | ||||
*/ | */ | ||||
td_softdep_cleanup(td); | td_softdep_cleanup(td); | ||||
/* | /* | ||||
* MUST abort all other threads before proceeding past here. | * MUST abort all other threads before proceeding past here. | ||||
*/ | */ | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
proc_set_p2_wexit(p); | |||||
/* | /* | ||||
* First check if some other thread or external request got | * First check if some other thread or external request got | ||||
* here before us. If so, act appropriately: exit or suspend. | * here before us. If so, act appropriately: exit or suspend. | ||||
* We must ensure that stop requests are handled before we set | * We must ensure that stop requests are handled before we set | ||||
* P_WEXIT. | * P_WEXIT. | ||||
*/ | */ | ||||
thread_suspend_check(0); | thread_suspend_check(0); | ||||
while (p->p_flag & P_HADTHREADS) { | while (p->p_flag & P_HADTHREADS) { | ||||
▲ Show 20 Lines • Show All 1,204 Lines • Show Last 20 Lines |
Is PCATCH correct here? Upon receiving a signal we'll spin in the loop until p_singlethr goes to zero.