From 52433d15d4ea215b1cf0f613c42d2d5cbfdf1b81 Mon Sep 17 00:00:00 2001 From: davidxu Date: Wed, 11 Jun 2003 01:08:33 +0000 Subject: Fix error in my last commit. Correctly maintain p_maxthrwaits and unlock sched_lock. --- sys/kern/kern_kse.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sys/kern/kern_kse.c') diff --git a/sys/kern/kern_kse.c b/sys/kern/kern_kse.c index 367f97b..bb4e3f0 100644 --- a/sys/kern/kern_kse.c +++ b/sys/kern/kern_kse.c @@ -1637,6 +1637,7 @@ thread_userret(struct thread *td, struct trapframe *frame) max_threads_hits++; PROC_LOCK(p); mtx_lock_spin(&sched_lock); + p->p_maxthrwaits++; while (p->p_numthreads > max_threads_per_proc) { upcalls = 0; FOREACH_KSEGRP_IN_PROC(p, kg2) { @@ -1648,13 +1649,15 @@ thread_userret(struct thread *td, struct trapframe *frame) if (upcalls >= max_threads_per_proc) break; mtx_unlock_spin(&sched_lock); - p->p_maxthrwaits++; if (msleep(&p->p_numthreads, &p->p_mtx, PPAUSE|PCATCH, - "maxthreads", NULL)) - break; - p->p_maxthrwaits--; - mtx_lock_spin(&sched_lock); + "maxthreads", NULL)) { + mtx_lock_spin(&sched_lock); + break; + } else { + mtx_lock_spin(&sched_lock); + } } + p->p_maxthrwaits--; mtx_unlock_spin(&sched_lock); PROC_UNLOCK(p); } -- cgit v1.1