views:

60

answers:

1

The process running get stuck around 32 000 (± 5%)

~# cat /proc/sys/kernel/threads-max 127862

~# ulimit -s stack size (kbytes, -s) 2048

free memory available : 3,5 Go

Further more when I try basic command while the process is stuck like "top", I get the bash message : can't fork, not enough memory. Even if there is still 3,5 Go of free memory.

What could be limit the thread creation at 32 000 ?

+3  A: 

Threads are identified with Thread IDs (TIDs), which are just PIDs in Linux, and...

~% sysctl kernel.pid_max
kernel.pid_max = 32768

PIDs in Linux are 16-bit, and 32768 is already the maximum value allowed. With that many threads, you have just completely filled the operating system process table. I don't think you will be able to create more threads than that.

Anyways, there is something really wrong with your design if you need that many threads. There is really no justification to have that many.

Juliano
According to `man gettid` on my system thread IDs are not PIDs. Only for a single-threaded application is the thread id the same as the PID.
Troubadour
Also, it appears that `pid_t` on my system ultimately resolves to `int`.
Troubadour
It seems that did the trick ! Thank you Juliano !Yes I know the design is broken, we just needed to do some benchmark on a Core i7 to see how fast it switch from thread to thread
TheSquad
@user374215: What gettid(2) mentions is about the semantics of a PID and a TID. Yes, they are different. But in the internal process table, both processes and threads share the same namespace, and that namespace is limited by kernel.pid_max.
Juliano
In fact the server does not get me the usual "Fork" issue.... but the number of threads is still stuck at ± 32000It is very annoying !
TheSquad