David Schwartz writes:
> On Sep 29, 10:07 am, calvin <chima1...@[EMAIL PROTECTED]
> wrote:
>> Thanks, but this has nothing to do with predicater. The threads waits
>> on a cond "never" wake up, even some other threads broadcasts.
>> Also, this is rare, and only happens when CPU load is high. In 99.9%
>> time it works well. That's why I suspect it's a POSIX's bug.
>
> This bug usually occurs because a thread called pthread_cond_wait when
> it should not have. You must check the predicate before calling
> pthread_cond_wait.
...and the predicate must be protected by the mutex used in the cond_wait,
i.e. the mutex must be locked when modifying and when changing the
variables in the predicate.
--
Hallvard


|