sync with OpenBSD -current
This commit is contained in:
parent
b5356a44af
commit
12fde4069b
187 changed files with 1127 additions and 1365 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kern_exit.c,v 1.220 2024/01/19 01:43:26 bluhm Exp $ */
|
||||
/* $OpenBSD: kern_exit.c,v 1.221 2024/05/20 10:32:20 claudio Exp $ */
|
||||
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -132,8 +132,6 @@ exit1(struct proc *p, int xexit, int xsig, int flags)
|
|||
/* nope, multi-threaded */
|
||||
if (flags == EXIT_NORMAL)
|
||||
single_thread_set(p, SINGLE_EXIT);
|
||||
else if (flags == EXIT_THREAD)
|
||||
single_thread_check(p, 0);
|
||||
}
|
||||
|
||||
if (flags == EXIT_NORMAL && !(pr->ps_flags & PS_EXITING)) {
|
||||
|
@ -157,15 +155,27 @@ exit1(struct proc *p, int xexit, int xsig, int flags)
|
|||
}
|
||||
|
||||
/* unlink ourselves from the active threads */
|
||||
SCHED_LOCK(s);
|
||||
mtx_enter(&pr->ps_mtx);
|
||||
TAILQ_REMOVE(&pr->ps_threads, p, p_thr_link);
|
||||
SCHED_UNLOCK(s);
|
||||
pr->ps_threadcnt--;
|
||||
pr->ps_exitcnt++;
|
||||
|
||||
/*
|
||||
* if somebody else wants to take us to single threaded mode,
|
||||
* count ourselves out.
|
||||
*/
|
||||
if (pr->ps_single) {
|
||||
if (--pr->ps_singlecnt == 0)
|
||||
wakeup(&pr->ps_singlecnt);
|
||||
}
|
||||
|
||||
if ((p->p_flag & P_THREAD) == 0) {
|
||||
/* main thread gotta wait because it has the pid, et al */
|
||||
while (pr->ps_threadcnt > 1)
|
||||
tsleep_nsec(&pr->ps_threads, PWAIT, "thrdeath", INFSLP);
|
||||
while (pr->ps_threadcnt + pr->ps_exitcnt > 1)
|
||||
msleep_nsec(&pr->ps_threads, &pr->ps_mtx, PWAIT,
|
||||
"thrdeath", INFSLP);
|
||||
}
|
||||
mtx_leave(&pr->ps_mtx);
|
||||
|
||||
rup = pr->ps_ru;
|
||||
if (rup == NULL) {
|
||||
|
@ -352,9 +362,11 @@ exit1(struct proc *p, int xexit, int xsig, int flags)
|
|||
/* just a thread? detach it from its process */
|
||||
if (p->p_flag & P_THREAD) {
|
||||
/* scheduler_wait_hook(pr->ps_mainproc, p); XXX */
|
||||
if (--pr->ps_threadcnt == 1)
|
||||
mtx_enter(&pr->ps_mtx);
|
||||
pr->ps_exitcnt--;
|
||||
if (pr->ps_threadcnt + pr->ps_exitcnt == 1)
|
||||
wakeup(&pr->ps_threads);
|
||||
KASSERT(pr->ps_threadcnt > 0);
|
||||
mtx_leave(&pr->ps_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -829,7 +841,8 @@ process_zap(struct process *pr)
|
|||
if (otvp)
|
||||
vrele(otvp);
|
||||
|
||||
KASSERT(pr->ps_threadcnt == 1);
|
||||
KASSERT(pr->ps_threadcnt == 0);
|
||||
KASSERT(pr->ps_exitcnt == 1);
|
||||
if (pr->ps_ptstat != NULL)
|
||||
free(pr->ps_ptstat, M_SUBPROC, sizeof(*pr->ps_ptstat));
|
||||
pool_put(&rusage_pool, pr->ps_ru);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue