Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Parmap: fix deadlock in with futexes.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 8 Feb 2012 23:35:50 +0000 (00:35 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 9 Feb 2012 05:55:18 +0000 (06:55 +0100)
commitcf83c030fca0c16732983caee233c756c30bd66e
treee8a104795c33675ddff3ab1b0ad57ec7002b2459
parentb7d7072994877985a12c99591ad5c34dac347a8f
Parmap: fix deadlock in with futexes.

Also anticipate the possibility for futex_wait to return early with EINTR.

In the following scenario, the first wake(parmap.work) should not have
unlocked the second xbt_parmap_futex_worker_wait().

Master                                  Worker
======                                  ========
xbt_parmap_futex_master_signal() {
  parmap.thread_counter = 1
  ++parmap.work
                                        xbt_parmap_futex_worker_wait();
                                        xbt_parmap_work();
                                        xbt_parmap_futex_worker_signal();
                                        xbt_parmap_futex_worker_wait();
  wake(parmap.work) -- unlock -------->
}
xbt_parmap_work();
xbt_parmap_futex_master_wait();
                                        xbt_parmap_work();
                                        xbt_parmap_futex_worker_signal();
xbt_parmap_futex_master_signal();
xbt_parmap_work();
xbt_parmap_futex_master_wait();
  ===> LOCKED
                                        xbt_parmap_futex_worker_wait();
                                          ===> LOCKED
src/xbt/parmap.c