X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/f32b453f46c267383528c895fdc2913e80522399..ed5490f7bca3201e65838910db86ac95690a4a6b:/process.cpp?ds=inline diff --git a/process.cpp b/process.cpp index bf016ef..21eeb7a 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 @@ -144,6 +145,7 @@ void process::load_balance_loop() std::for_each(neigh.begin(), neigh.end(), bind(&process::ctrl_send, this, _1)); prev_load_broadcast = expected_load; + mutex.release(); sleep_until_date(next_iter_after_date, opt::min_lb_iter_duration); ctrl_receive(0.0); @@ -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;