Calling pthread_cond_signal without locking mutex

Posted by Maysam on Stack Overflow See other posts from Stack Overflow or by Maysam
Published on 2010-12-28T06:52:35Z Indexed on 2010/12/28 7:54 UTC
Read the original article Hit count: 283

Hi, I read somewhere that we should lock the mutex before calling pthread_cond_signal and unlock the mutext after calling it:

The pthread_cond_signal() routine is used to signal (or wake up) another thread which is waiting on the condition variable. It should be called after mutex is locked, and must unlock mutex in order for pthread_cond_wait() routine to complete.

My question is: isn't it OK to call pthread_cond_signal or pthread_cond_broadcast methods without locking the mutex?

© Stack Overflow or respective owner

Related posts about c++

Related posts about pthreads