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

Private GIT Repository
Add ability to delay the beginning of computations.
[loba.git] / process.cpp
index 65496385f08f45baf7d4e1b8015c78e7f54cf0e4..880bbd0b50c226bb3299470de8bc9ba114103d44 100644 (file)
@@ -99,7 +99,14 @@ int process::run()
     if (opt::log_rate >= 0)
         XBT_INFO("Initial load: %g", real_load);
     XBT_VERB("Starting...");
     if (opt::log_rate >= 0)
         XBT_INFO("Initial load: %g", real_load);
     XBT_VERB("Starting...");
+    mutex.acquire();
     lb_thread->start();
     lb_thread->start();
+    while (lb_iter <= opt::comp_iter_delay)
+        cond.wait(mutex);
+    mutex.release();
+    double sleep_duration = opt::comp_time_delay - MSG_get_clock();
+    if (sleep_duration > 0.0)
+        MSG_process_sleep(sleep_duration);
     compute_loop();
     lb_thread->wait();
     XBT_VERB("Done.");
     compute_loop();
     lb_thread->wait();
     XBT_VERB("Done.");
@@ -113,7 +120,14 @@ void process::load_balance_loop()
 
     double next_iter_after_date = MSG_get_clock() + opt::min_lb_iter_duration;
     while (still_running()) {
 
     double next_iter_after_date = MSG_get_clock() + opt::min_lb_iter_duration;
     while (still_running()) {
-        ++lb_iter;
+        if (lb_iter == opt::comp_iter_delay) {
+            mutex.acquire();
+            ++lb_iter;
+            cond.signal();
+            mutex.release();
+        } else {
+            ++lb_iter;
+        }
 
         if (opt::log_rate && lb_iter % opt::log_rate == 0) {
             if (opt::bookkeeping)
 
         if (opt::log_rate && lb_iter % opt::log_rate == 0) {
             if (opt::bookkeeping)