I am writing some code that generates quite a lot of threads (about 512 at the moment, but in the future it may become higher). Each of the threads performs only a small number of operations, so I want the overhead of having the threads hosted on the system to be minimal.
I set the stack size with pthread_attr_setstacksize(), and I can get the minimum allowable stack size from PTHREAD_STACK_MIN. But my question is: Is it safe to use PTHREAD_STACK_MINfor thread stack size? . How can I calculate how much stack I need? Are there any hidden overheads that I will need to add to my calculations?
Also, are there any other methods that can be used to reduce the load on threads in the system?
source
share