From: Arnaud Giersch Date: Mon, 30 Oct 2017 11:13:56 +0000 (+0100) Subject: Be safe in case of spurious wakeup of xbt_os_cond_wait. X-Git-Tag: v3.18~344 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/56c4467d40a5579c5d56204ee0af0f17d0304069 Be safe in case of spurious wakeup of xbt_os_cond_wait. --- diff --git a/src/include/xbt/parmap.hpp b/src/include/xbt/parmap.hpp index 35a7e069c9..3eeb6a2080 100644 --- a/src/include/xbt/parmap.hpp +++ b/src/include/xbt/parmap.hpp @@ -338,7 +338,7 @@ template void Parmap::PosixSynchro::master_signal() template void Parmap::PosixSynchro::master_wait() { xbt_os_mutex_acquire(done_mutex); - if (this->parmap.thread_counter < this->parmap.num_workers) { + while (this->parmap.thread_counter < this->parmap.num_workers) { /* wait for all workers to be ready */ xbt_os_cond_wait(done_cond, done_mutex); } @@ -360,7 +360,7 @@ template void Parmap::PosixSynchro::worker_wait(unsigned round) { xbt_os_mutex_acquire(ready_mutex); /* wait for more work */ - if (this->parmap.work_round != round) { + while (this->parmap.work_round != round) { xbt_os_cond_wait(ready_cond, ready_mutex); } xbt_os_mutex_release(ready_mutex);