Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New XBT module: file
[simgrid.git] / examples / simdag / sd_fail.c
index 0c19e37..f8f29cf 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2006-2010, 2012-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -6,7 +6,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include "simdag/simdag.h"
+#include "simgrid/simdag.h"
 #include "xbt/ex.h"
 #include "xbt/log.h"
 
@@ -19,6 +19,8 @@ int main(int argc, char **argv)
   double computation_amount[1];
   double communication_amount[2] = { 0 };
   SD_workstation_t workstation_list[1];
+  xbt_dynar_t ret;
+
   /* initialization of SD */
   SD_init(&argc, argv);
 
@@ -29,13 +31,16 @@ int main(int argc, char **argv)
    * will stop */
   XBT_INFO("First test: COMP_SEQ task");
   task = SD_task_create_comp_seq("Poor task", NULL, 2e10);
+  SD_task_watch(task, SD_FAILED);
+  SD_task_watch(task, SD_DONE);
 
   XBT_INFO("Schedule task '%s' on workstation 'Faulty Host'",
            SD_task_get_name(task));
 
   SD_task_schedulel(task, 1, SD_workstation_get_by_name("Faulty Host"));
 
-  SD_simulate(-1.0);
+  ret = SD_simulate(-1.0);
+  xbt_dynar_free(&ret);
 
   SD_task_dump(task);
 
@@ -49,7 +54,8 @@ int main(int argc, char **argv)
   SD_task_schedulel(task, 1, SD_workstation_get_by_name("Safe Host"));
 
   XBT_INFO("Run the simulation again");
-  SD_simulate(-1.0);
+  ret = SD_simulate(-1.0);
+  xbt_dynar_free(&ret);
 
   SD_task_dump(task);
   XBT_INFO("Task '%s' start time: %f, finish time: %f",
@@ -63,6 +69,9 @@ int main(int argc, char **argv)
   XBT_INFO("Second test: NON TYPED task");
 
   task = SD_task_create("Poor parallel task", NULL, 2e10);
+  SD_task_watch(task, SD_FAILED);
+  SD_task_watch(task, SD_DONE);
+
   computation_amount[0] = 2e10;
 
   XBT_INFO("Schedule task '%s' on workstation 'Faulty Host'",
@@ -72,7 +81,8 @@ int main(int argc, char **argv)
   SD_task_schedule(task, 1, workstation_list,
           computation_amount, communication_amount,-1);
 
-  SD_simulate(-1.0);
+  ret = SD_simulate(-1.0);
+  xbt_dynar_free(&ret);
 
   SD_task_dump(task);
 
@@ -90,7 +100,8 @@ int main(int argc, char **argv)
                    computation_amount, communication_amount,-1);
 
   XBT_INFO("Run the simulation again");
-  SD_simulate(-1.0);
+  ret = SD_simulate(-1.0);
+  xbt_dynar_free(&ret);
 
   SD_task_dump(task);
   XBT_INFO("Task '%s' start time: %f, finish time: %f",