Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow how_long to be negative
authorthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 3 Jul 2006 08:42:24 +0000 (08:42 +0000)
committerthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 3 Jul 2006 08:42:24 +0000 (08:42 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2466 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/simdag/sd_test.c
src/simdag/sd_global.c

index ec7047c..35d35cd 100644 (file)
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include "simdag/simdag.h"
 #include "xbt/ex.h"
+#include "xbt/log.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test,
                             "Logging specific to this SimDag example");
@@ -11,6 +12,8 @@ int main(int argc, char **argv) {
   /* initialisation of SD */
   SD_init(&argc, argv);
 
+  /*  xbt_log_control_set("sd.thres=debug");*/
+
   if (argc < 2) {
      INFO1("Usage: %s platform_file", argv[0]);
      INFO1("example: %s sd_platform.xml", argv[0]);
@@ -33,10 +36,6 @@ int main(int argc, char **argv) {
   SD_task_dependency_add(NULL, NULL, taskD, taskC);
   /*  SD_task_dependency_add(NULL, NULL, taskA, taskD); /\* deadlock */
 
-  /* watch points */
-  /*  SD_task_watch(taskB, SD_DONE);*/
-
-
   /* let's launch the simulation! */
 
   int workstation_number = 2;
@@ -63,7 +62,7 @@ int main(int argc, char **argv) {
   SD_task_t *changed_tasks;
   int i;
 
-  changed_tasks = SD_simulate(100);
+  changed_tasks = SD_simulate(0.001);
   
   while (changed_tasks[0] != NULL) {
     INFO0("Tasks whose state has changed:");
index 8716913..ffd30c7 100644 (file)
@@ -88,7 +88,7 @@ void SD_create_environment(const char *platform_file) {
  * when a watch point is reached, or when no more task can be executed.
  * Then you can call SD_simulate() again.
  * 
- * \param how_long maximum duration of the simulation
+ * \param how_long maximum duration of the simulation (a negative value means no time limit)
  * \return a NULL-terminated array of \ref SD_task_t whose state has changed.
  * \see SD_task_schedule(), SD_task_watch()
  */
@@ -135,7 +135,11 @@ SD_task_t* SD_simulate(double how_long)
 
   /* main loop */
   elapsed_time = 0.0;
-  while (elapsed_time >= 0.0 && total_time < how_long && !sd_global->watch_point_reached) {
+  while (elapsed_time >= 0.0 &&
+        (how_long < 0.0 || total_time < how_long) &&
+        !sd_global->watch_point_reached) {
+
+    DEBUG1("Total time: %f", total_time);
 
     elapsed_time = surf_solve();
     if (elapsed_time > 0.0)