Pthread_create Error Codes 11
Contents |
I agree with asking the next question in the threading group.] >i have a code that uses pthread, but when i use pthread_create() >method it returns error code 11. That would depend on what error 11 is. On my how to find pthread_threads_max system, errno.h says: #define EDEADLK 11 /* Resource deadlock avoided */ /* 11 was EAGAIN */ pthread error handling So, 11 once was EAGAIN, which is a known return for pthread_create(). It may still be on your implementation. My system's man page says: pthread error codes to string The pthread_create() function will fail if: [EAGAIN] The system lacked the necessary resources to create another thread, or the system-imposed limit on the total number of threads in a process [PTHREAD_THREADS_MAX] would be exceeded. >I have found out that this error; return code from pthread_create() is 11 error detail: resource temporarily unavailable is often >because of exceeding the THREAD_MAX limit for the process. But i want >to use only about 24 threads at a given time, and i destroy the >threads (or atleast i thought so) can someone tell me what i am doing >wrong here it would be of great help! thanks! My next guess is that your system won't allow a user process to run 24 (additional) threads. But most of what I can say about pthreads is guesses. The experts
How To Find Pthread_threads_max Ubuntu
in comp.programming.threads know this stuff inside and out. -- Drew Lawson Some men's dreams for others turn to nightmares. I never would have thought this in my wildest dreams. Drew Lawson, May 27, 2009 #1 Advertisements Antoninus Twink Guest On 27 May 2009 at 16:51, Drew Lawson wrote: > Harshith <> writes: >>i have a code that uses pthread, but when i use pthread_create() >>method it returns error code 11. > > That would depend on what error 11 is. On my system, errno.h says: > #define EDEADLK 11 /* Resource deadlock avoided */ > /* 11 was EAGAIN */ > > So, 11 once was EAGAIN, which is a known return for pthread_create(). > It may still be on your implementation. It seems likely that it is, given the code that produced it. Of course, he can find out for sure by passing the return value from pthread_create() to strerror(). Antoninus Twink, May 28, 2009 #2 Advertisements Show Ignored Content Want to reply to this thread or ask your own question? It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum. Sign Up Now! Similar Threads pthread_create for class ? vertigo, Aug 28, 2004, in forum: Java Replies: 4 Views: 1,125 Tor Iver Wilhelmsen Aug 29, 2004 Object Argument passing in pthread_create nightowl, Oct 21, 2
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site
Pthread_create Return
About Us Learn more about Stack Overflow the company Business Learn more about pthread_create resource temporarily unavailable hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join pthread_attr_setstacksize the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How do I get the http://www.thecodingforums.com/threads/re-pthread_create-returns-error-code-11.685758/ error code from pthread_join up vote 2 down vote favorite The following code fails to create join pthreads and the message "join failed" is printed. How do I get more information about the failure and it's cause? pthread_t aThread[MAX_LENGTH]; int errCode[MAX_LENGTH]; char returnVal; for(int i = 0; i < MAX_LENGTH; i++) { if((errCode[i] = pthread_create(&aThread[i], NULL, &findMatch, &fpArgs)) != 0) printf("error creating thread %d\n", errCode[i]); http://stackoverflow.com/questions/19286698/how-do-i-get-the-error-code-from-pthread-join if(!pthread_join(aThread[i], (void**)&returnVal)) printf("join failed\n i is %d", i); } EDIT: actually join returned no error and I made a mistake. The if statment shouldn't have the ! because join returns a non-zero number if there is a problem which evaluates to true. c pthreads pthread-join share|improve this question edited Oct 10 '13 at 4:44 asked Oct 10 '13 at 3:44 Celeritas 3,9611256111 1 Your cast of your returnVal address to a void** is undefined behavior. Unless sizeof(char) == sizeof(void*) on your system (which I can all-but-guarantee you it is not) It doesn't look like you're using it anyway, and NULL is a viable option, so you may rather just pthread_join(aThread[i], NULL); Further, pthread_join returns zero (0) on success, so testing it for failure with ! is backwards. Finally, you don't want to do it this way anyway, you want to start them all, then join them all. What you have here is literally no better than single threaded. –WhozCraig Oct 10 '13 at 4:18 add a comment| 4 Answers 4 active oldest votes up vote 2 down vote accepted I pointed this out in comment, but it deserves amplification. Your returnVal usage is wro
in the non-detached mode, and the limited available memory https://www.parkes.atnf.csiro.au/observing/documentation/computing_notes/linux_threads.html in some system stack is consumed. At that point no new threads can be created in non-detached mode until those threads are detached/killed, or the parent process(es) killed and restarted. Solution: create the threads in the detached state with the pthread_attr_setdetachstate call, e.g.; pthread_attr_init error codes (&id_attr); pthread_attr_setdetachstate(&id_attr, PTHREAD_CREATE_DETACHED); pthread_create( , &id_attr, , ); unless you really need the threads in the joinable (non-detached) state, in which case you will have a fixed upper limit to the number of joinable threads active at any one time. In the 2.4 kernels how to find I've examined this limit appears to be 256 threads for each parent process(?). Some of this is documented in the man help for pthread_attr_init. However the man help for pthread_create makes no mention of the ENOMEM return and what it means, which is rather confusing. In the Linux 2.2 kernels I've examined the behaviour is slightly different. The system default for the maximum joinable threads alive at any one time seems to be 1024 (rather than 256), and pthread_create returns an error code 11 EAGAIN, and a global errno value of 4 ("Interrupted system call"). The solution is the same as for 2.4: if your process creates lots of threads, make them detached or manage carefully their maximum instantaneous population. John Reynolds December 2004 [an error occurred while processing this directive]