LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   thread creation fails after a number of iteration (http://www.linuxquestions.org/questions/programming-9/thread-creation-fails-after-a-number-of-iteration-644848/)

sudevank 05-26-2008 09:13 AM

thread creation fails after a number of iteration
 
Hi,
I am running one service which creates three levels of threads . (ie main thread creates a thread , new one creates another like that ) and I am waiting for all threads by pthread_join call. The logic looks like below. But after a number(around 1500) of iteration pthread_create fails with error EAGAIN. Anybody having any idea?

main()

while (1)
{
create(thread1)
sleepforsometime()
}

thread1()
{

for i times
{
create (thread2)

}
wait for i threads //(thread2)

}
thread2()
{
do some works
return
}

Hko 05-26-2008 09:45 AM

Quote:

Originally Posted by sudevank (Post 3164988)
I am running one service which creates three levels of threads . (ie main thread creates a thread , new one creates another like that ) [...] But after a number(around 1500) of iteration pthread_create fails with error EAGAIN.

3 nesting levels, creating about 1500 threads each?
So, roughly: 3375000000 thread are created, and then your program fails reporting "EAGAIN" (which means according to the man page "not enough system resources").
Quote:

Anybody having any idea?
No. Sorry. Must be a kernel bug or something.


All times are GMT -5. The time now is 06:06 AM.