Thread Synchronization
extern pthread_cond_t job_cv;
extern struct job_req *create_job();
extern pthread_mutex_t job_lock;
struct job_req *curr_job;
curr_job == create_job();
pthread_mutex_lock(&job_lock);
pthread_cond_signal(&job_cv);
pthread_mutex_unlock(&job_lock);
extern struct job_req *job_dequeue();
struct job_req *curr_job;
pthread_mutex_lock(job_lock);
pthread_cond_wait(&job_cv, &job_lock);
curr_job = job_dequeue();
pthread_mutex_unlock(&job_lock);
Author | Title | Tracks | Home