From: Arnaud Giersch Date: Tue, 8 Mar 2011 22:21:36 +0000 (+0100) Subject: Protect concurrent access to real_load. X-Git-Tag: v0.1~85 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/3c79bbd2b5d237ebb9f045a768ac611a6bc7851c?ds=inline;hp=-c Protect concurrent access to real_load. Is it really needed? --- 3c79bbd2b5d237ebb9f045a768ac611a6bc7851c diff --git a/BUGS b/BUGS index 5d493ad..5cc1040 100644 --- a/BUGS +++ b/BUGS @@ -1,6 +1,3 @@ -Faut-il protéger les accès concurrents à real_load, entre compute_loop -et load_balance_loop ? - ======================================================================== Il semblerait qu'il y ait un bug dans SG 3.5, et qu'on ne puisse pas utiliser MSG_comm_waitany() pour l'émetteur *et* le récepteur sans diff --git a/process.cpp b/process.cpp index bf016ef..3df086b 100644 --- a/process.cpp +++ b/process.cpp @@ -126,6 +126,7 @@ void process::load_balance_loop() ++lb_iter; } + mutex.acquire(); if (!opt::bookkeeping) expected_load = real_load - get_sum_of_to_send(); // nothing to do with opt::bookkeeping @@ -134,6 +135,7 @@ void process::load_balance_loop() XBT_INFO("(%u:%u) current load: %g", lb_iter, comp_iter, real_load); XBT_VERB("... expected load: %g", expected_load); } + mutex.release(); if (expected_load > 0.0) load_balance(); @@ -172,16 +174,20 @@ void process::compute_loop() double next_iter_after_date = MSG_get_clock() + opt::min_comp_iter_duration; while (still_running()) { // receive + mutex.acquire(); if (real_load > 0.0) data_receive(0.0); else data_receive(opt::min_comp_iter_duration); + mutex.release(); comm.data_flush(false); // send + mutex.acquire(); std::for_each(neigh.begin(), neigh.end(), bind(&process::data_send, this, _1)); + mutex.release(); if (real_load == 0.0) continue;