From 45f517dc85cc6c2ed4ebce27de4f75c00271f945 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 17 Jul 2012 15:44:20 +0200 Subject: [PATCH 1/1] Fix a bug making that the simulation ran longer than expected MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If you asked for 3 seconds, and then had a task terminating after 2 seconds, the function simulated for 5 seconds. Now, the time already spent in the loop in previous rounds is properly taken into account. Thanks to Guillaume Serrière for detecting the issue. --- src/simdag/sd_global.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simdag/sd_global.c b/src/simdag/sd_global.c index 00512b1c76..1ca32d068f 100644 --- a/src/simdag/sd_global.c +++ b/src/simdag/sd_global.c @@ -258,7 +258,7 @@ xbt_swag_t SD_simulate_swag(double how_long) { XBT_DEBUG("Total time: %f", total_time); - elapsed_time = surf_solve(how_long > 0 ? surf_get_clock() + how_long : -1.0); + elapsed_time = surf_solve(how_long > 0 ? surf_get_clock() + how_long - total_time: -1.0); XBT_DEBUG("surf_solve() returns %f", elapsed_time); if (elapsed_time > 0.0) total_time += elapsed_time; -- 2.20.1