Subj : Re: Real cause of spurious wakeups To : comp.programming.threads From : David Hopwood Date : Thu Mar 31 2005 09:55 pm Alexander Terekhov wrote: > Vladimir Prus wrote: > >>can somebody explain the real reason why spurious wakeups are possible. That >>is, why call to pthread_cond_wait can return without >>pthread_cond_broadcast/pthread_cond_signal. > > Because apart from realtime scheduling, > pthread_cond_broadcast/pthread_cond_signal can be implemented as nop. > > No kidding. > > cond_wait: mutex::release_guard guard(mutex); sleep(random()); > > cond_signal: nop > > cond_broadcast: nop This is a very inefficient implementation that would not be used in practice, so it doesn't answer the OP's question. -- David Hopwood .