Skip to main content
gamedev.net
🔒 Locked

Threads

Started by Conn 3 replies 750+ views
Original Post
Conn
Conn
Hi, I working on a app that contains a number of threads, and i have encountered a problem with starting threads. Im using pthread btw. For some reason im only allowed to start 15 threads all together. Im able to start all the threads if i rearrange the order of them but only 15 at one time. Anyone know if theres a limitation in the system or the compiler. Im using Visual Studio 2005 Professional Edition.
Evil Steve
Evil Steve
What happens when you try to start the 16th thread? Does it crash, or does it return an error? If it returns an error, what error code is it?
Conn
Conn
Sorry for the late reply,
pthread_create returns 11
cobru
cobru
error code 11 = EAGAIN.

from the manpage of pthread_create (I'm using it on linux, though):
This function may return the following errors:
EAGAIN'
Not enough system resources to create a process for the new
thread, or more than
PTHREAD_THREADS_MAX' threads are
already active.


So, either you have PTHREAD_THREADS_MAX = 15 or you don't have enough system resources to create thread number 16.

You can try setting a smaller stack for the threads via pthread_attr_setstacksize() and if you can create more than 15 threads at a time, then your problem is resources, not PTHREAD_THREADS_MAX.
Q: How many programmers does it take to write a nice piece of software?A: MORE.
Evil Steve
Evil Steve
I suspect that the problem is PTHREAD_THREADS_MAX rather than the amount of free system resources. 15 threads, plus your main thread is 16, which seems like a sensible number for PTHREAD_THREADS_MAX. Also, I have Outlook running at the moment with 19 threads (On Windows) without any problems.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.