diff options
author | davidxu <davidxu@FreeBSD.org> | 2003-06-11 01:08:33 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2003-06-11 01:08:33 +0000 |
commit | 52433d15d4ea215b1cf0f613c42d2d5cbfdf1b81 (patch) | |
tree | 91b0355af22d00b486ee1180e49944af24b92dd8 /sys/kern | |
parent | 3b8fff9e4cedc4d9df3fb1ff39f5b668abdb9676 (diff) | |
download | FreeBSD-src-52433d15d4ea215b1cf0f613c42d2d5cbfdf1b81.zip FreeBSD-src-52433d15d4ea215b1cf0f613c42d2d5cbfdf1b81.tar.gz |
Fix error in my last commit. Correctly maintain p_maxthrwaits and unlock
sched_lock.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_kse.c | 13 | ||||
-rw-r--r-- | sys/kern/kern_thread.c | 13 |
2 files changed, 16 insertions, 10 deletions
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); } diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 367f97b..bb4e3f0 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.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); } |