From: Martin Quinson Date: Tue, 17 Jul 2012 13:44:20 +0000 (+0200) Subject: Fix a bug making that the simulation ran longer than expected X-Git-Tag: v3_8~271 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/45f517dc85cc6c2ed4ebce27de4f75c00271f945?hp=f35266523c599068c264085705e4d3a5b01b75ca Fix a bug making that the simulation ran longer than expected 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. --- 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;