[patch] off by one issue in sys/kern/kern_thr.c

Alexander Best arundel at freebsd.org
Wed Feb 23 11:16:48 UTC 2011


hi there,

i think the following should be changed. with
kern.threads.max_threads_per_proc=N, a process should be able to maintain
N threads and not N-1.

to verify simply use tools/test/pthread_vfork.

cheers.
alex

-- 
a13x
-------------- next part --------------
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c
index 75656f0..63bf1bc 100644
--- a/sys/kern/kern_thr.c
+++ b/sys/kern/kern_thr.c
@@ -153,7 +153,7 @@ create_thread(struct thread *td, mcontext_t *ctx,
 	p = td->td_proc;
 
 	/* Have race condition but it is cheap. */
-	if (p->p_numthreads >= max_threads_per_proc) {
+	if (p->p_numthreads > max_threads_per_proc) {
 		++max_threads_hits;
 		return (EPROCLIM);
 	}


More information about the freebsd-hackers mailing list