$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Roland Schwarz (roland.schwarz_at_[hidden])
Date: 2005-09-15 07:12:07
Anthony Williams schrieb:
>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.
>  
>
Oops,  how obvious. Shame on me  /:~/
It seems that I cannot easily get a test case that would show up my 
suspicion.
I considerably underestimated the difficulty to make sure all threads 
are currently
waiting on the same condition, and then fire them all together.
Altough I would very much appreciate if someone could tell me why it is 
not a
problem when the sequence: "wait then signal"  does occur, during the 
gate is closed.
It might very well be that this indeed _is_ no problem, I just can't see 
why.
Roland