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.
/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.