aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_kse.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2004-03-13 22:31:39 +0000
committerPeter Wemm <peter@FreeBSD.org>2004-03-13 22:31:39 +0000
commit37814395c12385fc105dde213843490046d9fade (patch)
tree889a20a7869b0ea5ed48e021f905fe415332a764 /sys/kern/kern_kse.c
parentf8325b428c167b4383a687b684036d20dd2ff1a2 (diff)
downloadsrc-37814395c12385fc105dde213843490046d9fade.tar.gz
src-37814395c12385fc105dde213843490046d9fade.zip
Push Giant down a little further:
- no longer serialize on Giant for thread_single*() and family in fork, exit and exec - thread_wait() is mpsafe, assert no Giant - reduce scope of Giant in exit to not cover thread_wait and just do vm_waitproc(). - assert that thread_single() family are not called with Giant - remove the DROP/PICKUP_GIANT macros from thread_single() family - assert that thread_suspend_check() s not called with Giant - remove manual drop_giant hack in thread_suspend_check since we know it isn't held. - remove the DROP/PICKUP_GIANT macros from thread_suspend_check() family - mark kse_create() mpsafe
Notes
Notes: svn path=/head/; revision=126932
Diffstat (limited to 'sys/kern/kern_kse.c')
-rw-r--r--sys/kern/kern_kse.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/sys/kern/kern_kse.c b/sys/kern/kern_kse.c
index 037266aa358b..19952049a569 100644
--- a/sys/kern/kern_kse.c
+++ b/sys/kern/kern_kse.c
@@ -1331,13 +1331,14 @@ thread_exit(void)
/*
* Do any thread specific cleanups that may be needed in wait()
- * called with Giant held, proc and schedlock not held.
+ * called with Giant, proc and schedlock not held.
*/
void
thread_wait(struct proc *p)
{
struct thread *td;
+ mtx_assert(&Giant, MA_NOTOWNED);
KASSERT((p->p_numthreads == 1), ("Multiple threads in wait1()"));
KASSERT((p->p_numksegrps == 1), ("Multiple ksegrps in wait1()"));
FOREACH_THREAD_IN_PROC(p, td) {
@@ -1468,6 +1469,7 @@ kse_purge(struct proc *p, struct thread *td)
void
thread_alloc_spare(struct thread *td, struct thread *spare)
{
+
if (td->td_standin)
return;
if (spare == NULL)
@@ -1876,7 +1878,7 @@ thread_single(int force_exit)
td = curthread;
p = td->td_proc;
- mtx_assert(&Giant, MA_OWNED);
+ mtx_assert(&Giant, MA_NOTOWNED);
PROC_LOCK_ASSERT(p, MA_OWNED);
KASSERT((td != NULL), ("curthread is NULL"));
@@ -1933,11 +1935,9 @@ thread_single(int force_exit)
* In the mean time we suspend as well.
*/
thread_suspend_one(td);
- DROP_GIANT();
PROC_UNLOCK(p);
mi_switch(SW_VOL);
mtx_unlock_spin(&sched_lock);
- PICKUP_GIANT();
PROC_LOCK(p);
mtx_lock_spin(&sched_lock);
}
@@ -1991,6 +1991,7 @@ thread_suspend_check(int return_instead)
td = curthread;
p = td->td_proc;
+ mtx_assert(&Giant, MA_NOTOWNED);
PROC_LOCK_ASSERT(p, MA_OWNED);
while (P_SHOULDSTOP(p)) {
if (P_SHOULDSTOP(p) == P_STOPPED_SINGLE) {
@@ -2016,8 +2017,6 @@ thread_suspend_check(int return_instead)
* Assumes that P_SINGLE_EXIT implies P_STOPPED_SINGLE.
*/
if ((p->p_flag & P_SINGLE_EXIT) && (p->p_singlethread != td)) {
- while (mtx_owned(&Giant))
- mtx_unlock(&Giant);
if (p->p_flag & P_SA)
thread_exit();
else
@@ -2035,11 +2034,9 @@ thread_suspend_check(int return_instead)
thread_unsuspend_one(p->p_singlethread);
}
}
- DROP_GIANT();
PROC_UNLOCK(p);
mi_switch(SW_INVOL);
mtx_unlock_spin(&sched_lock);
- PICKUP_GIANT();
PROC_LOCK(p);
}
return (0);