Date: 2001-07-02 08:56:07
paquette_at_[hidden] (Jeff Paquette) wrote:
> PMFJI, but doesn't this (Win32 pseudo code):
> .. do work ..
> WaitForMultipleObjects(mutex, event, wait_all);
> .. do more work ..
> work in the same fashion as the monitor mentioned above sans race
No. The inclusion of mutex again in your second wait has no effect
since you already own it. The pattern requires atomically releasing the
mutex and entering the wait state. You can easily do this with the
SignalObjectAndWait() function, but that is only available on NT/2K/XP.
A portable version requires more complicated logic.
Schmidt and Pyarali have written about this:
-- Duncan Harris, Sapio Design Ltd, Manchester, U.K.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk