Calling pthread_cond_signal without locking mutex
- by Maysam
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?