Boost logo

Boost :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2005-09-15 04:20:26


Roland Schwarz <roland.schwarz_at_[hidden]> writes:

> 1) Is this corect code with respect to condition variable
> semantics (posix thread semantics?)

No.

do_flag only signals one thread waiting on the condition. If this is one of
the do_work threads, then it will wake up, go back to sleep, and the
notification has been swallowed. Since the main thread didn't wake up, it
won't break out of the loop checking global_flag. Since the only threads that
do notification are the main thread and the do_flag thread, once all the
threads have entered their waiting loop, if the do_flag notification wakes
anyone other than the main thread, we have deadlock.

Anthony

-- 
Anthony Williams
Software Developer
Just Software Solutions Ltd
http://www.justsoftwaresolutions.co.uk

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk