À un moment donné dans ma fonction, il atteindraitPthread Sync - pthread_cond_wait
pthread_cond_wait (& cond_state, & b_state);
Lorsqu'un signal est envoyé et réactivé ce fil. Est-ce qu'il essaie immédiatement de verrouiller le mutex avant d'appeler Enter?
void Enter(int g, int timer){
pthread_mutex_lock(&b_state);
if (room.state == 2 || room.state == g)
{
pthread_mutex_unlock(&b_state);
Leave();
}
else
{
pthread_cond_wait(&cond_state, &b_state);
Enter(g, timer); //Try to enter again
}
}
J'ai un problème quand si un thread est allé dormir, une fois réveillé, il sera bloquée à mutex_lock après appelé Entrée.