>From: "Nadav Har'El" <[EMAIL PROTECTED]>
>To: Yosi <[EMAIL PROTECTED]>
>CC: [EMAIL PROTECTED]
>Subject: Re: Creating maxium number of threads for a process
>Date: Sun, 12 May 2002 12:40:47 +0300
>
>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.

I find that hard to belive that a thread (otherwise known as a
light weight process) will have a bigger overhead than an actual process.
Besides, the file descriptor number is dynamic (/proc and ulimit) and I
made sure that I can open hundreds of thousands of files.

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


Each thread is created with a stack of 16KB. I set the limit in the shell
to 8KB but that didn't make a difference. Before I execute my program
I have 24MB free RAM and after creating 1500 threads I have 4MB free.
and 512MB free swap.

Yosi

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


=================================================================
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