views:

51

answers:

2

Using the pthread library in C, is it possible to send a SIGSTOP signal to an individual thread?

I want to ensure that even though I create N threads in a loop, all should start executing only when all of them have been created.

I ask because the man page for pthread_kill() mentions:

Signal dispositions are process-wide: if a signal handler is installed, the handler will be invoked in the thread thread, but if the disposition of the signal is "stop", "continue", or "terminate", this action will affect the whole process.

+2  A: 

You should use mutexes and conditions for that.

Here is a great example on how to do just that.

Pablo Santa Cruz
+2  A: 

Barriers (see pthread_barrier_init) are an even easier way to accomplish what you need.

zvrba