Is pthread_cond_signal(3) man page correct?
eischen at vigrid.com
Mon Feb 28 02:26:35 UTC 2011
On Feb 27, 2011, at 4:26 PM, Yuri <yuri at rawbw.com> wrote:
> Forwarding to standards@ and davidxu@ per Garrett Cooper suggestion.
> Also I want to add that I came to this question while observing behavior consistent with multiple wakeup on FreeBSD-8.1. The heavily multi-threaded code that assumes that only one thread can be woken up by one pthread_cond_signal call crashes, and the only reasonable explanation so far is that more than one threads are actually being woken up.
It depends on what you mean by wakeup. More than one thread may unblock, but only one thread will have the mutex locked after wakeup. If other threads awake (as allowed by POSIX), they will have to check the state protected by the mutex to see if they really should awake and continue or if they should block again on the CV. A wakeup from pthread_cond_wait() should not assume that he was the only thread awoken.
More information about the freebsd-standards