Subj : proper order of pthread_mutex_unlock() and pthread_cond_signal() To : comp.programming.threads From : el_bandido Date : Mon Jan 31 2005 11:41 pm Hi, Consider following pseudo-code: void foo() { pthread_mutex_lock(&mux); while (in_use == 0) { pthread_cond_wait(&cond, &mux); } in_use=0; pthread_mutex_unlock(&mux); pthread_cond_signal(&cond); } 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. Regards, Roberto Nibali, ratz -- echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq' | dc .