On Sun, May 12, 2002, Yosi wrote about "Creating maxium number of threads for a 
process":
>...
> A small test that creates a lot of threads fails exactly at 1531 threads.
> Trying to create more threads past this figure fails with the error
> "Interrupted system call" (error number 11).

Could you try creating as many processes (with fork), not pthreads, and see
if that succeeds?

Maybe pthreads adds some overheads (file descriptors, stacks) that you don't
have with actual processes.

> Did I miss something in the configuration of the machine or environment that
> limits me?

Here is my guess (but it's only a guess):

In LinuxThreads, each thread is given a stack with a constant size, which
(in the latest glibc implementations) is determined by the "stacksize" limit
(run limit or ulimit to see that limit).

With the default 8MB stack per thread, 1531 threads require 12 GB (!!) of
virtual memory, which is actually impossible on a normal 32bit Linux, so
I assumed you manually lowered this limit.
If you lowered it to 2MB, 1531 stacks need 3062 MB of virtual memory - and
this is almost the absolute limit you can get (with the additional 1 GB
mapped to the kernel).

Note that under older glibc's/kernels, each thread always gets 2MB regardless
of the RLIMIT_STACK limit - so please test this on a recent system.

To test if this is the problem, please try to reduce the amount of stack
space each thread takes up; try doing:

        limit stacksize 512k

before running your test program.

Or, do do it in C, do in your program

#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
        ....
        struct rlimit limit;
        limit.rlim_cur=512*1024;
        limit.rlim_max=0;
        setrlimit(RLIMIT_STACK, &limit);

before starting any threads.


-- 
Nadav Har'El                        |        Sunday, May 12 2002, 1 Sivan 5762
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Hi! I'm a signature virus! Copy me into
http://nadav.harel.org.il           |your signature to help me spread!

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to