X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/3ca418ecc742d8447431f44380d6da38541edb2e..f53cc3ffa9262bf3265e218c5d2700971ec39638:/process.cpp diff --git a/process.cpp b/process.cpp index c519cd8..3df086b 100644 --- a/process.cpp +++ b/process.cpp @@ -21,7 +21,7 @@ double process::total_load_exit = 0.0; namespace { - void sleep_until_date(double& date, double duration = 0.0) + void sleep_until_date(double& date, double duration) { double sleep_duration = date - MSG_get_clock(); if (sleep_duration > 0.0) @@ -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;