Avoding multiple thread spawns in pthreads

Posted by madman on Stack Overflow See other posts from Stack Overflow or by madman
Published on 2010-05-24T10:33:39Z Indexed on 2010/05/25 3:21 UTC
Read the original article Hit count: 266

Filed under:
|
|

Hi StackOverflow,

I have an application that is parallellized using pthreads. The application has a iterative routine call and a thread spawn within the rountine (pthread_create and pthread_join) to parallelize the computation intensive section in the routine. When I use an instrumenting tool like PIN to collect the statistics the tool reports statistics for several threads(no of threads x no of iterations). I beleive it is because it is spawning new set of threads each time the routine is called.

  1. How can I ensure that I create the thread only once and all successive calls use the threads that have been created first.

  2. When I do the same with OpenMP and then try to collect the statistics, I see that the threads are created only once. Is it beacause of the OpenMP runtime ?

Thanks.

© Stack Overflow or respective owner

Related posts about c++

Related posts about c