+/* 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 "private.h"
#include "xbt/sysdep.h"
#include "xbt/dynar.h"
SD_global_t sd_global = NULL;
-/* $Id$ */
-
-/* Copyright (c) 2007 Arnaud Legrand.
- 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. */
-
XBT_LOG_EXTERNAL_CATEGORY(sd_kernel);
XBT_LOG_EXTERNAL_CATEGORY(sd_task);
XBT_LOG_EXTERNAL_CATEGORY(sd_workstation);
sd_global->task_number = 0;
surf_init(argc, argv);
- xbt_cfg_set_string(_surf_cfg_set, "workstation_model", "ptask_L07");
+ xbt_cfg_set_string(_surf_cfg_set, "workstation/model", "ptask_L07");
}
/**
DEBUG0("SD_create_environment");
- surf_timer_model_init(platform_file);
surf_config_models_setup(platform_file);
parse_platform_file(platform_file);
__SD_workstation_create(surf_workstation, NULL);
}
- xbt_dict_foreach(link_set, cursor, name, surf_link) {
+ xbt_dict_foreach(surf_model_resource_set(surf_network_model), cursor, name, surf_link) {
__SD_link_create(surf_link, NULL);
}
surf_action_t action;
SD_task_t *res = NULL;
xbt_dynar_t changed_tasks = xbt_dynar_new(sizeof(SD_task_t), NULL);
- unsigned int iter;
+ unsigned int iter, depcnt;
static int first_time = 1;
SD_CHECK_INIT_DONE();
- INFO0("Starting simulation...");
+ VERB0("Starting simulation...");
if (first_time) {
surf_presolve(); /* Takes traces into account */
/* explore the ready tasks */
xbt_swag_foreach_safe(task, task_safe, sd_global->ready_task_set) {
- INFO1("Executing task '%s'", SD_task_get_name(task));
+ VERB1("Executing task '%s'", SD_task_get_name(task));
if (__SD_task_try_to_run(task) && !xbt_dynar_member(changed_tasks, &task))
xbt_dynar_push(changed_tasks, &task);
}
xbt_dynar_foreach(model_list, iter, model) {
while ((action = xbt_swag_extract(model->states.done_action_set))) {
task = action->data;
- INFO1("Task '%s' done", SD_task_get_name(task));
+ task->start_time = surf_workstation_model->action_get_start_time(task->surf_action);
+ task->finish_time = surf_get_clock();
+ VERB1("Task '%s' done", SD_task_get_name(task));
DEBUG0("Calling __SD_task_just_done");
__SD_task_just_done(task);
DEBUG1("__SD_task_just_done called on task '%s'",
xbt_dynar_push(changed_tasks, &task);
/* remove the dependencies after this task */
- while (xbt_dynar_length(task->tasks_after) > 0) {
- xbt_dynar_get_cpy(task->tasks_after, 0, &dependency);
- dst = dependency->dst;
- SD_task_dependency_remove(task, dst);
+ xbt_dynar_foreach(task->tasks_after, depcnt, dependency){
+ dst = dependency->dst;
+ if (dst->unsatisfied_dependencies>0)
+ dst->unsatisfied_dependencies--;
+
+ if (!(dst->unsatisfied_dependencies) && __SD_task_is_scheduled(dst))
+ __SD_task_set_state(dst, SD_READY);
/* is dst ready now? */
if (__SD_task_is_ready(dst) && !sd_global->watch_point_reached) {
- INFO1("Executing task '%s'", SD_task_get_name(dst));
+ VERB1("Executing task '%s'", SD_task_get_name(dst));
if (__SD_task_try_to_run(dst) &&
!xbt_dynar_member(changed_tasks, &task))
xbt_dynar_push(changed_tasks, &task);
/* let's see which tasks have just failed */
while ((action = xbt_swag_extract(model->states.failed_action_set))) {
task = action->data;
- INFO1("Task '%s' failed", SD_task_get_name(task));
+ task->start_time = surf_workstation_model->action_get_start_time(task->surf_action);
+ task->finish_time = surf_get_clock();
+ VERB1("Task '%s' failed", SD_task_get_name(task));
__SD_task_set_state(task, SD_FAILED);
surf_workstation_model->action_unref(action);
task->surf_action = NULL;
}
xbt_dynar_free(&changed_tasks);
- INFO0("Simulation finished");
+ VERB0("Simulation finished");
DEBUG3("elapsed_time = %f, total_time = %f, watch_point_reached = %d",
elapsed_time, total_time, sd_global->watch_point_reached);
DEBUG1("current time = %f", surf_get_clock());