Bug 70058 - PTHREAD_THREAD_MAX 1024 in pthread.h, 256 in practice
Summary: PTHREAD_THREAD_MAX 1024 in pthread.h, 256 in practice
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 7.3
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-07-29 19:35 UTC by Rob Sherwood
Modified: 2016-11-24 15:09 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2002-07-29 19:35:45 UTC
Embargoed:


Attachments (Terms of Use)

Description Rob Sherwood 2002-07-29 19:35:41 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.78 [en] (X11; U; Linux 2.4.7-10 i686; Nav)

Description of problem:
glibc-devel-2.2.4-24
the max number of threads per process (PTHREAD_THREAD_MAX) is listed in
/usr/include/pthread.h as 1024, but it would appear to be compiled into glibc as
256 (after 254 threads, I cannot create new threads).  I don't believe other
things are the limiting factors:
cputime         unlimited
filesize        unlimited
datasize        unlimited
stacksize       8192 kbytes
coredumpsize    unlimited
memoryuse       unlimited
descriptors     1024
memorylocked    unlimited
maxproc         512
openfiles       1024

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.write a program that forks off more than 256 thread
2.
3.
	

Actual Results:  only 254 threads are created

Expected Results:  if you believe pthread.h, you should be able to 
create up to 1024 threads

Additional info:

I know I can just recompile glibc myself to get around
this, but I thought you would like to know. RH72 is 
also like this.  I have recompiled the same code on
a slackware machine with glibc2.1.2 (?; it was recent
at least) and got the full 1024 threads.

Comment 1 Jakub Jelinek 2002-07-30 10:31:18 UTC
/lib/i686/libpthread.so.0 (and most of non-IA-32 architectures) use FLOATING_STACKS
implementation, ie. there are no longer fixed hardcoded 2MB stacks for each
thread but programs can choose how big stacks to use and how many threads can
thus be created.
Unless the stack size is modified through pthread attribute functions on a
per-thread basis, the stack size is taken from the stack size rlimit (if it
is unlimited, it is assumed to be 8MB, as otherwise one couldn't create more
than one thread).
Your application can either do something like setrlimit (RLIMIT_STACK, { 1MB, 1MB });
before spawning first thread, or use pthread_attr_setstacksize etc.


Note You need to log in before you can comment on or make changes to this bug.