Bug 70058 - PTHREAD_THREAD_MAX 1024 in pthread.h, 256 in practice
PTHREAD_THREAD_MAX 1024 in pthread.h, 256 in practice
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
7.3
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-07-29 15:35 EDT by Rob Sherwood
Modified: 2016-11-24 10:09 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-07-29 15:35:45 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Rob Sherwood 2002-07-29 15:35:41 EDT
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 06:31:18 EDT
/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.