On Sun, May 12, 2002, Yosi wrote about "Re: Creating maxium number of threads for a 
process":
> 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.

There's almost nothing "lighter" about threads than processes in Linux...

Anyway, testing the same thing with 1600 forks instead of 1600 threads should
be very easy, and I think you'd benefit from doing it. My guess is that
creating 1600 processes (all of them running sleep(), please) will work just
fine for you. Would you humor me, please?

> Besides, the file descriptor number is dynamic (/proc and ulimit) and I
> made sure that I can open hundreds of thousands of files.

Ok, then that's not the problem.

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

As I said, the problem with stack space isn't actual RAM (before you touch
the stack pages, they are not created) but rather *virtual memory* space:
All sibling threads share the same 4GB address space, of which only 3GB
(or 2GB or 1GB, depending on your kernel and how you compiled it) can be
used by the user space.

It's a curious coincidence that 2MB multiplied by the number of threads you
had comes out almost EXACTLY to 3GB. Are you sure you set the stack size to
16 kb? Can you show us the code that does it? What Kernel, Glibc and
distribution versions are you using? I'm assuming you're using an i386 machine.
If it's really a freak coincidence, and I'm just leading you on a wild-
goose-chase, I'm sorry...

By the way, when running, say, 1500 threads, can you show us what you
see in "ps aux" for one of these threads? I'm mainly interested in the VSZ
column, which is the size of the address-space the program uses.

-- 
Nadav Har'El                        |        Sunday, May 12 2002, 1 Sivan 5762
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |I have an open mind - it's just closed
http://nadav.harel.org.il           |for repairs.

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