From owner-freebsd-threads@FreeBSD.ORG Sat Jan 31 22:13:07 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BB34A16A4CF for ; Sat, 31 Jan 2004 22:13:07 -0800 (PST) Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7591343D2D for ; Sat, 31 Jan 2004 22:13:06 -0800 (PST) (envelope-from rodrigc@crodrigues.org) Received: from h00609772adf0.ne.client2.attbi.com ([66.31.45.197]) by comcast.net (sccrmhc13) with ESMTP id <20040201061305016003ub2be>; Sun, 1 Feb 2004 06:13:05 +0000 Received: from h00609772adf0.ne.client2.attbi.com (localhost.crodrigues.org [127.0.0.1])i116CDbq006384 for ; Sun, 1 Feb 2004 01:12:13 -0500 (EST) (envelope-from rodrigc@h00609772adf0.ne.client2.attbi.com) Received: (from rodrigc@localhost)i116CDDA006383 for freebsd-threads@freebsd.org; Sun, 1 Feb 2004 01:12:13 -0500 (EST) (envelope-from rodrigc) Date: Sun, 1 Feb 2004 01:12:12 -0500 From: Craig Rodrigues To: freebsd-threads@freebsd.org Message-ID: <20040201061212.GA6349@crodrigues.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Subject: pthread_create() blocks if maxthreads reached? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Feb 2004 06:13:07 -0000 Hi, I wrote the following small test program to spawn a large number of threads. ================================================================== #include #include #include #include #define NUM 100000 void *thr(void *p) { select(0, NULL, NULL, NULL, NULL); return p; } int main() { pthread_t t[NUM]; int ret=0; int i; for(i=0; ; ++i) { printf("Entering pthread_create...\n"); ret = pthread_create(&t[i], NULL, thr, NULL); printf("Left pthread_create...\n"); if( ret != 0 ) { printf("%d %s\n", ret, strerror(ret)); break; } } printf("Max threads reached at: %d\n", i); return 0; } ============================================================== If I link this program with -lthr or -lc_r, the program will terminate. If I link with -lpthread, the program seems to block in the pthread_create() call, instead of returning EAGAIN (to indicate that a new thread cannot be created due to hitting some system limit). Any ideas on this? Thanks. -- Craig Rodrigues http://crodrigues.org rodrigc@crodrigues.org