Subj : Re: proper order of pthread_mutex_unlock() and pthread_cond_signal() To : comp.programming.threads From : David Schwartz Date : Mon Jan 31 2005 08:52 pm wrote in message news:41feb0c1_2@news.cybercity.ch... > I've read that pthread_cond_signal(&cond) should actually be inside the > locked code segment (critical section) and not outside as shown in the > example above. Any comments on why one of the correct solutions is the way > to go? Both work for me but I'm quite confident that one is wrong. Generally, placing the signal outside the critical section results in better performance. It is possible to, if incredibly clever, create a situation where this doesn't work (because the pthread_cond_signal, being later, can wake a thread that went to sleep after the mutex was released, and thus is waiting on the wrong predicate), but such a situation has never occured in the wild. DS .