Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Parmap: protect against wraparound for round.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 8 Feb 2012 22:58:25 +0000 (23:58 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 9 Feb 2012 05:48:01 +0000 (06:48 +0100)
src/xbt/parmap.c

index 103fe7f..8219493 100644 (file)
@@ -347,7 +347,7 @@ static void xbt_parmap_posix_worker_wait(xbt_parmap_t parmap, unsigned round)
 {
   xbt_os_mutex_acquire(parmap->ready_mutex);
   /* wait for more work */
-  if (parmap->work < round) {
+  if (parmap->work != round) {
     xbt_os_cond_wait(parmap->ready_cond, parmap->ready_mutex);
   }
   xbt_os_mutex_release(parmap->ready_mutex);
@@ -416,7 +416,7 @@ static void xbt_parmap_futex_worker_wait(xbt_parmap_t parmap, unsigned round)
 {
   unsigned work = parmap->work;
   /* wait for more work */
-  if (work < round)
+  if (work != round)
     futex_wait(&parmap->work, work);
 }
 #endif
@@ -472,7 +472,7 @@ static void xbt_parmap_busy_master_signal(xbt_parmap_t parmap)
 static void xbt_parmap_busy_worker_wait(xbt_parmap_t parmap, unsigned round)
 {
   /* wait for more work */
-  while (parmap->work < round) {
+  while (parmap->work != round) {
     xbt_os_thread_yield();
   }
 }