On Tue, 15 Sep 1998, Henrik Nordstrom wrote:
> A condition variable must always be associated with a
> mutex, to avoid the race condition where a thread prepares
> to wait on a condition variable and another thread signals
> the condition just before the first thread actually waits
> on it.
In addition to that (the caller side):
A thread may call pthread_cond_signal() or pthread_cond_broadcast()
without holding the mutex with which threads calling pthread_cond_wait()
or pthread_cond_timedwait() have associated with the condition variable
during their waits. However, predictable scheduling behavior is only
guaranteed if the associated mutex is locked by a thread calling
pthread_cond_signal() or pthread_cond_broadcast().
Again, nobody is saying that one cannot send/receive signals without locking
the condition variable first. One can. One can even get some benefits from
not following the recommended protocol. At a price.
Alex.
Received on Tue Jul 29 2003 - 13:15:54 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:11:55 MST