I am writing a code wherein I am making my threads wait till I do a pthread_cond_broadcast. I have three threads in this code. Threads line2_thread and line3_thread, are running in the order of their priority like they are supposed to run. However, my third thread doesn't even enter its thread function (line4_thread). Can anyone tell me why is my main() not being able to call my line4_thread ? pthread_cond_t sstart; pthread_mutex_t sstart_mutex;
void *l3_thread(void *arg){
pthread_mutex_lock(&sstart_mutex);
pthread_cond_wait(&sstart, &sstart_mutex);
pthread_mutex_unlock(&sstart_mutex);
/*do something*/
pthread_exit(NULL);
}
void *l2_thread(void *arg){
pthread_mutex_lock(&sstart_mutex);
pthread_cond_wait(&sstart, &sstart_mutex);
pthread_mutex_unlock(&sstart_mutex);
/*do something*/
pthread_exit(NULL);
}
void *l4_thread(void *arg){
pthread_mutex_lock(&sstart_mutex);
pthread_cond_wait(&sstart, &sstart_mutex);
pthread_mutex_unlock(&sstart_mutex);
/*do something*/
pthread_exit(NULL);
}
int main(){
pthread_cond_init(&sstart, NULL);
//thread creation
pthread_cond_broadcast(&sstart);
pthread_cond_destroy(&sstart);
pthread_mutex_destroy(&sstart_mutex);
return 0;
}