Pthread_cond_signal causing deadlock?

When we call pthread_cond_wait(&cond, &lock), the lock will be released and pthread will wait on the condition variable. When it gets the signal on the conditional variable then it will acquire the lock and will come out of pthread_cond_wait(). In your program, you acquired a mutex lock before calling pthread_cond_broadcast(&cond) hence pthread_cond_wait(&cond, &lock) cannot take the lock when it receives the signal.

I think that will be the reason for the deadlock.

Stupid error. I was destroying the mutex and condvar before executing signal and wait. To reproduce, just move the destroy functions before the joining the threads in the main function.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions