X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/526e1f382ddc9f0010c41a526f3029af769162c9..245565c060611ddfed5067ab4000e91e440c402c:/process.cpp?ds=sidebyside diff --git a/process.cpp b/process.cpp index 36bdff0..dfbf123 100644 --- a/process.cpp +++ b/process.cpp @@ -26,6 +26,8 @@ int process::process_counter = 0; double process::total_load_average; double process::load_diff_threshold; +std::atomic process::convergence_counter(0); + namespace { void sleep_until_date(double& date, double duration) @@ -69,6 +71,7 @@ process::process(int argc, char* argv[]) proc_mutex->acquire(); process_counter++; + convergence_counter++; total_load_init += real_load; total_load_running += real_load; total_load_average = total_load_running / process_counter; @@ -291,12 +294,14 @@ void process::convergence_check() XBT_VERB("current load has diverged: %g (%.4g%%)", real_load, 100.0 * load_diff / average); convergence = -1.0; + convergence_counter++; } } else { if (converged) { XBT_VERB("current load has converged: %g (%.4g%%)", real_load, 100.0 * load_diff / average); convergence = MSG_get_clock(); + convergence_counter--; } } } @@ -324,6 +329,10 @@ bool process::still_running() XBT_VERB("Reached comp_maxiter: %d/%d", comp_iter, opt::comp_maxiter); last_status = false; + } else if (opt::exit_on_convergence && convergence_counter == 0) { + XBT_VERB("Global convergence detected"); + last_status = false; + } else if (opt::exit_on_close && close_received) { XBT_VERB("Close received"); last_status = false;