]> AND Private Git Repository - loba.git/blobdiff - process.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Spell sig_atomic_t as std::sig_atomic_t.
[loba.git] / process.cpp
index bf016ef0078225a27b1dc0c50605d1407282ac2d..54fea8aeb2ed8534d4561715b9595b0950c967ef 100644 (file)
@@ -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
@@ -141,14 +142,14 @@ void process::load_balance_loop()
         print_loads(true, xbt_log_priority_debug);
 
         // send
+        comm.ctrl_flush(false);
         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);
-
-        comm.ctrl_flush(false);
     }
 
     XBT_VERB("Going to finalize for %s...", __func__);
@@ -172,16 +173,19 @@ 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);
-
-        comm.data_flush(false);
+        mutex.release();
 
         // send
+        comm.data_flush(false);
+        mutex.acquire();
         std::for_each(neigh.begin(), neigh.end(),
                       bind(&process::data_send, this, _1));
+        mutex.release();
 
         if (real_load == 0.0)
             continue;