summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_kse.c
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2003-04-01 01:26:20 +0000
committerjeff <jeff@FreeBSD.org>2003-04-01 01:26:20 +0000
commit1b4d7b91cef2a324650912a6c4a57c1247f72de9 (patch)
treefe9429d1c952f94fe7724a5e8d93774c365108da /sys/kern/kern_kse.c
parentddd831445867d7b38b022286ecc4d99f0bcbca48 (diff)
downloadFreeBSD-src-1b4d7b91cef2a324650912a6c4a57c1247f72de9.zip
FreeBSD-src-1b4d7b91cef2a324650912a6c4a57c1247f72de9.tar.gz
- Borrow the KSE single threading code for exec and exit. We use the check
if (p->p_numthreads > 1) and not a flag because action is only necessary if there are other threads. The rest of the system has no need to identify thr threaded processes. - In kern_thread.c use thr_exit1() instead of thread_exit() if P_THREADED is not set.
Diffstat (limited to 'sys/kern/kern_kse.c')
-rw-r--r--sys/kern/kern_kse.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/kern/kern_kse.c b/sys/kern/kern_kse.c
index b9c85f8..3699461 100644
--- a/sys/kern/kern_kse.c
+++ b/sys/kern/kern_kse.c
@@ -1813,7 +1813,7 @@ thread_single(int force_exit)
PROC_LOCK_ASSERT(p, MA_OWNED);
KASSERT((td != NULL), ("curthread is NULL"));
- if ((p->p_flag & P_THREADED) == 0)
+ if ((p->p_flag & P_THREADED) == 0 && p->p_numthreads == 1)
return (0);
/* Is someone already single threading? */
@@ -1872,6 +1872,7 @@ thread_single(int force_exit)
* In the mean time we suspend as well.
*/
thread_suspend_one(td);
+ /* XXX If you recursed this is broken. */
mtx_unlock(&Giant);
PROC_UNLOCK(p);
p->p_stats->p_ru.ru_nvcsw++;
@@ -1961,15 +1962,18 @@ thread_suspend_check(int return_instead)
if ((p->p_flag & P_SINGLE_EXIT) && (p->p_singlethread != td)) {
while (mtx_owned(&Giant))
mtx_unlock(&Giant);
- thread_exit();
+ if (p->p_flag & P_THREADED)
+ thread_exit();
+ else
+ thr_exit1();
}
+ mtx_assert(&Giant, MA_NOTOWNED);
/*
* When a thread suspends, it just
* moves to the processes's suspend queue
* and stays there.
*/
- mtx_assert(&Giant, MA_NOTOWNED);
thread_suspend_one(td);
PROC_UNLOCK(p);
if (P_SHOULDSTOP(p) == P_STOPPED_SINGLE) {
OpenPOWER on IntegriCloud