Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_thread.c
Show All 39 Lines | |||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/rangelock.h> | #include <sys/rangelock.h> | ||||
#include <sys/resourcevar.h> | #include <sys/resourcevar.h> | ||||
#include <sys/sdt.h> | #include <sys/sdt.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#include <sys/sched.h> | #include <sys/sched.h> | ||||
#include <sys/sleepqueue.h> | #include <sys/sleepqueue.h> | ||||
#include <sys/selinfo.h> | #include <sys/selinfo.h> | ||||
#include <sys/syscallsubr.h> | |||||
#include <sys/sysent.h> | #include <sys/sysent.h> | ||||
#include <sys/turnstile.h> | #include <sys/turnstile.h> | ||||
#include <sys/ktr.h> | #include <sys/ktr.h> | ||||
#include <sys/rwlock.h> | #include <sys/rwlock.h> | ||||
#include <sys/umtx.h> | #include <sys/umtx.h> | ||||
#include <sys/cpuset.h> | #include <sys/cpuset.h> | ||||
#ifdef HWPMC_HOOKS | #ifdef HWPMC_HOOKS | ||||
#include <sys/pmckern.h> | #include <sys/pmckern.h> | ||||
▲ Show 20 Lines • Show All 881 Lines • ▼ Show 20 Lines | while (thread_suspend_check_needed()) { | ||||
/* | /* | ||||
* If the process is waiting for us to exit, | * If the process is waiting for us to exit, | ||||
* this thread should just suicide. | * this thread should just suicide. | ||||
* Assumes that P_SINGLE_EXIT implies P_STOPPED_SINGLE. | * Assumes that P_SINGLE_EXIT implies P_STOPPED_SINGLE. | ||||
*/ | */ | ||||
if ((p->p_flag & P_SINGLE_EXIT) && (p->p_singlethread != td)) { | if ((p->p_flag & P_SINGLE_EXIT) && (p->p_singlethread != td)) { | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
tidhash_remove(td); | |||||
/* | /* | ||||
* Allow Linux emulation layer to do some work | * Allow Linux emulation layer to do some work | ||||
* before thread suicide. | * before thread suicide. | ||||
*/ | */ | ||||
if (__predict_false(p->p_sysent->sv_thread_detach != NULL)) | if (__predict_false(p->p_sysent->sv_thread_detach != NULL)) | ||||
(p->p_sysent->sv_thread_detach)(td); | (p->p_sysent->sv_thread_detach)(td); | ||||
kern_thr_exit(td); | |||||
PROC_LOCK(p); | panic("stopped thread did not exit"); | ||||
jhb: I intend to commit this first as a separate commit but included it here for context. (The… | |||||
tdsigcleanup(td); | |||||
umtx_thread_exit(td); | |||||
PROC_SLOCK(p); | |||||
thread_stopped(p); | |||||
thread_exit(); | |||||
} | } | ||||
PROC_SLOCK(p); | PROC_SLOCK(p); | ||||
thread_stopped(p); | thread_stopped(p); | ||||
if (P_SHOULDSTOP(p) == P_STOPPED_SINGLE) { | if (P_SHOULDSTOP(p) == P_STOPPED_SINGLE) { | ||||
if (p->p_numthreads == p->p_suspcount + 1) { | if (p->p_numthreads == p->p_suspcount + 1) { | ||||
thread_lock(p->p_singlethread); | thread_lock(p->p_singlethread); | ||||
wakeup_swapper = thread_unsuspend_one( | wakeup_swapper = thread_unsuspend_one( | ||||
▲ Show 20 Lines • Show All 243 Lines • Show Last 20 Lines |
I intend to commit this first as a separate commit but included it here for context. (The second half of the commit message above is actually for this change.) We are already missing an 'racct' call here and I would have to duplicate the ptrace stop, etc.
One caveat is that kern_thr_exit() is now seemingly misnamed and/or in the wrong place as it probably should be a function in this file as it isn't really specific to the "thr" system calls.