"Cannot change the model after the initialization");
val = xbt_cfg_get_string(_sd_cfg_set, name);
- find_resource_description(surf_workstation_resource_description,
- surf_workstation_resource_description_size,
+ find_model_description(surf_workstation_model_description,
+ surf_workstation_model_description_size,
val);
}
"Cannot change the model after the initialization");
val = xbt_cfg_get_string(_sd_cfg_set, name);
- find_resource_description(surf_cpu_resource_description,
- surf_cpu_resource_description_size, val);
+ find_model_description(surf_cpu_model_description,
+ surf_cpu_model_description_size, val);
}
/* callback of the workstation_model variable */
"Cannot change the model after the initialization");
val = xbt_cfg_get_string(_sd_cfg_set, name);
- find_resource_description(surf_network_resource_description,
- surf_network_resource_description_size, val);
+ find_model_description(surf_network_model_description,
+ surf_network_model_description_size, val);
}
/* create the config set and register what should be */
/* To split the string in commands, and the cursors */
xbt_dynar_t set_strings;
char *str;
- int cpt;
+ unsigned int cpt;
if (!control_string)
return;
DEBUG0("SD_create_environment");
sd_config_init();
- surf_timer_resource_init(platform_file);
+ surf_timer_model_init(platform_file);
workstation_model_name =
xbt_cfg_get_string(_sd_cfg_set, "workstation_model");
DEBUG1("Model : %s", workstation_model_name);
workstation_id =
- find_resource_description(surf_workstation_resource_description,
- surf_workstation_resource_description_size,
+ find_model_description(surf_workstation_model_description,
+ surf_workstation_model_description_size,
workstation_model_name);
if (!strcmp(workstation_model_name, "compound")) {
xbt_ex_t e;
}
network_id =
- find_resource_description(surf_network_resource_description,
- surf_network_resource_description_size,
+ find_model_description(surf_network_model_description,
+ surf_network_model_description_size,
network_model_name);
cpu_id =
- find_resource_description(surf_cpu_resource_description,
- surf_cpu_resource_description_size,
+ find_model_description(surf_cpu_model_description,
+ surf_cpu_model_description_size,
cpu_model_name);
- surf_cpu_resource_description[cpu_id].resource_init(platform_file);
- surf_network_resource_description[network_id].resource_init(platform_file);
+ surf_cpu_model_description[cpu_id].model_init(platform_file);
+ surf_network_model_description[network_id].model_init(platform_file);
}
- DEBUG0("Call workstation_resource_init");
- surf_workstation_resource_description[workstation_id].
- resource_init(platform_file);
+ DEBUG0("Call workstation_model_init");
+ surf_workstation_model_description[workstation_id].
+ model_init(platform_file);
+
+ parse_platform_file(platform_file);
_sd_init_status = 2;
__SD_workstation_create(surf_workstation, NULL);
}
- xbt_dict_foreach(network_link_set, cursor, name, surf_link) {
+ xbt_dict_foreach(link_set, cursor, name, surf_link) {
__SD_link_create(surf_link, NULL);
}
SD_task_t *changed_tasks = NULL;
int changed_task_number = 0;
int changed_task_capacity = sd_global->task_number + 1;
- int i;
+ unsigned int iter;
static int first_time = 1;
SD_CHECK_INIT_DONE();
}
if(how_long>0) {
- surf_timer_resource->extension_public->set(surf_get_clock()+how_long,
+ surf_timer_model->extension_public->set(surf_get_clock()+how_long,
NULL,NULL);
}
sd_global->watch_point_reached = 0;
while (elapsed_time >= 0.0 &&
(how_long < 0.0 || total_time < how_long) &&
!sd_global->watch_point_reached) {
+ surf_model_t model = NULL;
/* dumb variables */
void *fun = NULL;
void *arg = NULL;
total_time += elapsed_time;
/* let's see which tasks are done */
- while ((action = xbt_swag_extract(surf_workstation_resource->common_public->states.done_action_set))) {
- task = action->data;
- INFO1("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'", SD_task_get_name(task));
-
- /* the state has changed */
- if (!task->state_changed) {
- task->state_changed = 1;
- changed_tasks[changed_task_number++] = task;
- /*
- if (changed_task_number == changed_task_capacity) {
- changed_task_capacity *= 2;
- changed_tasks = xbt_realloc(changed_tasks, sizeof(SD_task_t) * changed_task_capacity);
- }
- */
- changed_tasks[changed_task_number] = NULL;
- }
-
- /* 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(model_list, iter, model) {
+ while ((action = xbt_swag_extract(model->common_public->
+ states.done_action_set))) {
+ task = action->data;
+ INFO1("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'", SD_task_get_name(task));
- /* is dst ready now? */
- if (__SD_task_is_ready(dst) && !sd_global->watch_point_reached) {
- INFO1("Executing task '%s'", SD_task_get_name(dst));
- if (__SD_task_try_to_run(dst)) {
- changed_tasks[changed_task_number++] = dst;
- /*
+ /* the state has changed */
+ if (!task->state_changed) {
+ task->state_changed = 1;
+ changed_tasks[changed_task_number++] = task;
+ /*
if (changed_task_number == changed_task_capacity) {
- changed_task_capacity *= 2;
- changed_tasks = xbt_realloc(changed_tasks, sizeof(SD_task_t) * changed_task_capacity);
+ changed_task_capacity *= 2;
+ changed_tasks = xbt_realloc(changed_tasks, sizeof(SD_task_t) * changed_task_capacity);
+ }
+ */
+ changed_tasks[changed_task_number] = NULL;
+ }
+
+ /* 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);
+
+ /* is dst ready now? */
+ if (__SD_task_is_ready(dst) && !sd_global->watch_point_reached) {
+ INFO1("Executing task '%s'", SD_task_get_name(dst));
+ if (__SD_task_try_to_run(dst)) {
+ changed_tasks[changed_task_number++] = dst;
+ /*
+ if (changed_task_number == changed_task_capacity) {
+ changed_task_capacity *= 2;
+ changed_tasks = xbt_realloc(changed_tasks, sizeof(SD_task_t) * changed_task_capacity);
+ }
+ */
+ changed_tasks[changed_task_number] = NULL;
}
- */
- changed_tasks[changed_task_number] = NULL;
}
}
}
- }
- /* let's see which tasks have just failed */
- while ((action = xbt_swag_extract(surf_workstation_resource->common_public->states.failed_action_set))) {
- task = action->data;
- INFO1("Task '%s' failed", SD_task_get_name(task));
- __SD_task_set_state(task, SD_FAILED);
- surf_workstation_resource->common_public->action_free(action);
- task->surf_action = NULL;
-
- if (!task->state_changed) {
- task->state_changed = 1;
- changed_tasks[changed_task_number++] = task;
- /*
- if (changed_task_number == changed_task_capacity) {
- changed_task_capacity *= 2;
- changed_tasks = xbt_realloc(changed_tasks, sizeof(SD_task_t) * changed_task_capacity);
+ /* let's see which tasks have just failed */
+ while ((action = xbt_swag_extract(model->common_public->states.failed_action_set))) {
+ task = action->data;
+ INFO1("Task '%s' failed", SD_task_get_name(task));
+ __SD_task_set_state(task, SD_FAILED);
+ surf_workstation_model->common_public->action_free(action);
+ task->surf_action = NULL;
+
+ if (!task->state_changed) {
+ task->state_changed = 1;
+ changed_tasks[changed_task_number++] = task;
+ /*
+ if (changed_task_number == changed_task_capacity) {
+ changed_task_capacity *= 2;
+ changed_tasks = xbt_realloc(changed_tasks, sizeof(SD_task_t) * changed_task_capacity);
+ }
+ */
+ changed_tasks[changed_task_number] = NULL;
}
- */
- changed_tasks[changed_task_number] = NULL;
}
}
- while (surf_timer_resource->extension_public->get(&fun,(void*)&arg)) {
+ while (surf_timer_model->extension_public->get(&fun,(void*)&arg)) {
}
}
/* we must reset every task->state_changed */
- i = 0;
- while (changed_tasks[i] != NULL) {
- changed_tasks[i]->state_changed = 0;
- i++;
+ iter = 0;
+ while (changed_tasks[iter] != NULL) {
+ changed_tasks[iter]->state_changed = 0;
+ iter++;
}
INFO0("Simulation finished");