X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a6399ec5be5b63718e15d25d870212bef3955f4d..724ca046f77fe11ada8a28c60a2b33c0720a63b4:/examples/simdag/sd_fail.c diff --git a/examples/simdag/sd_fail.c b/examples/simdag/sd_fail.c new file mode 100644 index 0000000000..39ffe5d493 --- /dev/null +++ b/examples/simdag/sd_fail.c @@ -0,0 +1,62 @@ +/* Copyright (c) 2006, 2007, 2008, 2009, 2010. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#include +#include +#include "simdag/simdag.h" +#include "xbt/ex.h" +#include "xbt/log.h" + +XBT_LOG_NEW_DEFAULT_CATEGORY(sd_fail, + "Logging specific to this SimDag example"); + +int main(int argc, char **argv) +{ + SD_task_t task; + + /* initialization of SD */ + SD_init(&argc, argv); + + /* creation of the environment */ + SD_create_environment("./faulty_host.xml"); + + /* creation of a single task that will poorly fail when the workstation + * will stop */ + + task = SD_task_create_comp_seq("Poor task", NULL, 2e10); + + 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); + + SD_task_dump(task); + + XBT_INFO("Task %s has failed. %.f flops remain to be done", + SD_task_get_name(task), + SD_task_get_remaining_amount(task)); + + XBT_INFO("let's unschedule taks %s and reschedule it on the 'Safe Host'", + SD_task_get_name(task)); + SD_task_unschedule(task); + SD_task_schedulel(task, 1, SD_workstation_get_by_name("Safe Host")); + + XBT_INFO("Run the simulation again"); + SD_simulate(-1.0); + + SD_task_dump(task); + XBT_INFO("Task '%s' start time: %f, finish time: %f", + SD_task_get_name(task), + SD_task_get_start_time(task), + SD_task_get_finish_time(task)); + + SD_task_destroy(task); + + SD_exit(); + return 0; +}