Subj : Re: pthread_cond_signal() semantics To : comp.programming.threads From : Markus Elfring Date : Mon Jan 10 2005 09:48 pm "William Hoggarth" schrieb im Newsbeitrag news:v48Ed.23$IW2.8@newsfe1-gui.ntli.net... > Thanks for the replies, let's see if I understand correctly: > > William Hoggarth wrote: > > > I have a thread with similar to the following: > > > > while(1) { > > get_input(); > > > > pthread_mutex_lock(&mutex); > > copy_input_to_buffer(); > > pthread_cond_signal(&cond); > > pthread_mutex_unlock(&mutex); > > } > > Ok, let's see if I understand this correctly. > > 1) pthread_cond_signal(&cond) simply marks the waiting thread as waiting on > the mutex ( as if it had just called pthread_mutex_lock() and not > pthread_cond_wait() ). > > 2) pthread_mutex_unlock(&mutex) merely unlocks the mutex, allowing the > thread to reaquire the lock before the waiting thread can do so. > > 3) the most sensible way to get the behaviour I want is to have another > condition variable which signals when the data has been processed. > > Is this right? > > Thanks, > > William Hoggarth .