#include <pthread.h>
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
int do_work(void) {
int result;
if ((result = pthread_mutex_lock(&mut)) != 0) {
}
if ((result = pthread_cond_signal(&cond,&mut)) != 0) {
}
if ((result = pthread_mutex_unlock(&mut)) != 0) {
}
}
int wait_and_work(void) {
if ((result = pthread_mutex_lock(&mut)) != 0) {
}
while () {
if ((result = pthread_cond_wait(&cond, &mut)) != 0) {
}
}
if ((result = pthread_mutex_unlock(&mut)) != 0) {
}
}