+ double total_time = 0.0; /* we stop the simulation when total_time >= how_long */
+ double elapsed_time = 0.0;
+ int watch_point_reached = 0;
+ int i;
+ SD_task_t task;
+ surf_action_t surf_action;
+
+ surf_solve(); /* Takes traces into account. Returns 0.0 */
+
+ /* main loop */
+ while (elapsed_time >= 0.0 && total_time < how_long && !watch_point_reached) {
+ for (i = 0 ; i < xbt_dynar_length(sd_global->tasks); i++) {
+ xbt_dynar_get_cpy(sd_global->tasks, i, &task);
+ printf("Examining task '%s'...\n", SD_task_get_name(task));
+
+ /* if the task is scheduled and the dependencies are satisfied,
+ we can execute the task */
+ if (SD_task_get_state(task) == SD_SCHEDULED) {
+ printf("Task '%s' is scheduled.\n", SD_task_get_name(task));
+
+ if (xbt_dynar_length(task->tasks_before) == 0) {
+ printf("The dependencies are satisfied. Executing task '%s'\n", SD_task_get_name(task));
+ surf_action = __SD_task_run(task);
+ }
+ else {
+ printf("Cannot execute task '%s' because some depencies are not satisfied.\n", SD_task_get_name(task));
+ }
+ }
+ else {
+ printf("Task '%s' is not scheduled. Nothing to do.\n", SD_task_get_name(task));
+ }
+ }
+ elapsed_time = surf_solve();
+ if (elapsed_time > 0.0)
+ total_time += elapsed_time;
+ printf("Total time: %f\n", total_time);
+ }
+
+ return NULL;
+}
+
+void SD_test() {