Boost logo

Boost Users :

From: Zeljko Vrba (zvrba_at_[hidden])
Date: 2008-08-11 15:56:51


On Mon, Aug 11, 2008 at 10:46:43PM +0300, Peter Dimov wrote:
> Zeljko Vrba:
>
> >Even worse:
> >
> >A: push; unlock; gets preempted
> >B: wait_and_pop: succeeds, making the queue empty; unlocks the mutex
> >A: gets scheduled again, notifies the condvar which has no waiters
> >C: wait_and_pop: acquires mutex, sleeps on the condvar
>
> No. C doesn't sleep because the wait is guarded by the predicate
> the_queue.empty().
>

But the predicate is true: B suceeded in popping the item from the stack, and
made the stack empty [we assume that the stack was empty to begin with].
the_queue.empty() will return true after C has acquired mutex.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net