If pthread_cond_wait() requires locked mutex, doesn't it block the thread which changed condition?
Advertisements I need a two-threaded application. One thread prepare data, one process it. If there is no data to process, the second thread should sleep. Doing as tons of tutorials suggests: pthread_mutex_t mtx; pthread_cond_t cond; char *shared_data = NULL; char *process_data() { char *dt; pthread_mutex_lock(&mtx); if(!shared_data) pthread_cond_wait(&cond, &mtx); dt = strdup(shared_data); free(shared_data); shared_data = NULL;… Read More If pthread_cond_wait() requires locked mutex, doesn't it block the thread which changed condition?