Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix a bug making that the simulation ran longer than expected
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 17 Jul 2012 13:44:20 +0000 (15:44 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 17 Jul 2012 13:44:20 +0000 (15:44 +0200)
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

index 00512b1..1ca32d0 100644 (file)
@@ -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;