I would like to know what happens with the while
after a waiting thread is waked.
To avoid 'spurious wake-ups', the pthreads
documentation points out that you need to use pthread_cond_wait
inside a while
statement.
So, when the pthread_cond_wait
is called, the calling thread is blocked. And after signaled, the thread resume inside the while
.
On my code, I'm handling a pthread_cond_wait()
this way:
pthread_mutex_lock(&waiting_call_lock);
while(1) {
pthread_cond_wait(&queue_cond[thread_ctx], &waiting_call_lock);
break;
}
pthread_mutex_unlock(&waiting_call_lock);
The question is, it will try to enter the while again or somehow it break
the while and go on? Or, in that case, the break
after the pthread_cond_wait()
is necessary?