Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int count = 0;
- void thread_check()
- {
- //if condition to trigger thread stuff isn't met, abort
- if(!condition && count == 0)
- {
- return;
- }
- //thread counter
- count++;
- //all other threads waiting?
- if(count >= thread_count)
- {
- //yes, do stuff...
- //reset counter before we leave
- count = 0;
- //broadcast all threads to resume
- mutex_lock(&mutex); //<--- Hangs here
- pthread_cond_broadcast(&cond);
- mutex_unlock(&mutex);
- }
- else
- {
- //make thread wait...
- mutex_lock(&mutex);
- pthread_cond_wait(&cond, &mutex);
- mutex_unlock(&mutex);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment