From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 23 11:16:48 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1233) id CD38F1065836; Wed, 23 Feb 2011 11:16:48 +0000 (UTC) Date: Wed, 23 Feb 2011 11:16:48 +0000 From: Alexander Best To: freebsd-hackers@freebsd.org Message-ID: <20110223111648.GA41592@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="DocE+STaALJfprDB" Content-Disposition: inline Subject: [patch] off by one issue in sys/kern/kern_thr.c X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Feb 2011 11:16:48 -0000 --DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="kern_thr.c.diff" 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); } --DocE+STaALJfprDB--