X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/86a08ab9c895a99c7efb4ee38db24c3541deb6bd..ac4e0d6a72781d6b567bd45cdb2de02aa4b41d67:/src/surf/surf.c diff --git a/src/surf/surf.c b/src/surf/surf.c index a6fcd8db71..0ac05fb90e 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -106,24 +106,12 @@ int __surf_is_absolute_file_path(const char *file_path) #endif } -typedef struct surf_model_object { - surf_model_t model; -} s_surf_model_object_t, *surf_model_object_t; - static double NOW = 0; xbt_dynar_t model_list = NULL; tmgr_history_t history = NULL; lmm_system_t maxmin_system = NULL; xbt_dynar_t surf_path = NULL; -const char *surf_action_state_names[6] = { - "SURF_ACTION_READY", - "SURF_ACTION_RUNNING", - "SURF_ACTION_FAILED", - "SURF_ACTION_DONE", - "SURF_ACTION_TO_FREE", - "SURF_ACTION_NOT_IN_THE_SYSTEM" -}; /* Don't forget to update the option description in smx_config when you change this */ s_surf_model_description_t surf_network_model_description[] = { @@ -240,67 +228,6 @@ double generic_maxmin_share_resources(xbt_swag_t running_actions, return min; } -e_surf_action_state_t surf_action_get_state(surf_action_t action) -{ - surf_action_state_t action_state = - &(action->model_type->common_public->states); - - if (action->state_set == action_state->ready_action_set) - return SURF_ACTION_READY; - if (action->state_set == action_state->running_action_set) - return SURF_ACTION_RUNNING; - if (action->state_set == action_state->failed_action_set) - return SURF_ACTION_FAILED; - if (action->state_set == action_state->done_action_set) - return SURF_ACTION_DONE; - return SURF_ACTION_NOT_IN_THE_SYSTEM; -} - -double surf_action_get_start_time(surf_action_t action) -{ - return action->start; -} - -double surf_action_get_finish_time(surf_action_t action) -{ - return action->finish; -} - -void surf_action_free(surf_action_t * action) -{ - (*action)->model_type->common_public->action_cancel(*action); - free(*action); - *action = NULL; -} - -void surf_action_change_state(surf_action_t action, - e_surf_action_state_t state) -{ - surf_action_state_t action_state = - &(action->model_type->common_public->states); - XBT_IN2("(%p,%s)", action, surf_action_state_names[state]); - xbt_swag_remove(action, action->state_set); - - if (state == SURF_ACTION_READY) - action->state_set = action_state->ready_action_set; - else if (state == SURF_ACTION_RUNNING) - action->state_set = action_state->running_action_set; - else if (state == SURF_ACTION_FAILED) - action->state_set = action_state->failed_action_set; - else if (state == SURF_ACTION_DONE) - action->state_set = action_state->done_action_set; - else - action->state_set = NULL; - - if (action->state_set) - xbt_swag_insert(action, action->state_set); - XBT_OUT; -} - -void surf_action_set_data(surf_action_t action, void *data) -{ - action->data = data; -} XBT_LOG_EXTERNAL_CATEGORY(surf_cpu); XBT_LOG_EXTERNAL_CATEGORY(surf_kernel); @@ -324,11 +251,6 @@ XBT_LOG_EXTERNAL_CATEGORY(surf_network_gtnets); void surf_init(int *argc, char **argv) { - int i, j; - char *opt; - - const char *initial_path; - /* Connect our log channels: that must be done manually under windows */ XBT_LOG_CONNECT(surf_cpu, surf); XBT_LOG_CONNECT(surf_kernel, surf); @@ -350,38 +272,12 @@ void surf_init(int *argc, char **argv) #endif xbt_init(argc, argv); - if (!surf_path) { - - /* retrieves the current directory of the current process */ - initial_path = __surf_get_initial_path(); - - xbt_assert0((initial_path), - "__surf_get_initial_path() failed! Can't resolves current Windows directory"); - - surf_path = xbt_dynar_new(sizeof(char *), NULL); - xbt_dynar_push(surf_path, &initial_path); - - for (i = 1; i < *argc; i++) { - if (!strncmp(argv[i], "--surf-path=", strlen("--surf-path="))) { - opt = strchr(argv[i], '='); - opt++; - xbt_dynar_push(surf_path, &opt); - /*remove this from argv */ - for (j = i + 1; j < *argc; j++) { - argv[j - 1] = argv[j]; - } - argv[j - 1] = NULL; - (*argc)--; - i--; /* compensate effect of next loop incrementation */ - } - } - } if (!model_list) model_list = xbt_dynar_new(sizeof(surf_model_private_t), NULL); if (!history) history = tmgr_history_new(); - surf_config_init(argc,argv); + surf_config_init(argc, argv); } static char *path_name = NULL; @@ -433,7 +329,7 @@ void surf_exit(void) surf_config_finalize(); xbt_dynar_foreach(model_list, iter, model) { - model->common_private->finalize(); + model->model_private->finalize(); } if (maxmin_system) { @@ -467,7 +363,7 @@ void surf_presolve(void) double next_event_date = -1.0; tmgr_trace_event_t event = NULL; double value = -1.0; - surf_model_object_t model_obj = NULL; + surf_resource_t resource = NULL; surf_model_t model = NULL; unsigned int iter; @@ -478,14 +374,14 @@ void surf_presolve(void) break; while ((event = tmgr_history_get_next_event_leq(history, next_event_date, - &value, (void **) &model_obj))) { - model_obj->model->common_private->update_resource_state(model_obj, - event, value, - NOW); + &value, (void **) &resource))) { + resource->model->model_private->update_resource_state(resource, + event, value, + NOW); } } xbt_dynar_foreach(model_list, iter, model) { - model->common_private->update_actions_state(NOW, 0.0); + model->model_private->update_actions_state(NOW, 0.0); } } @@ -495,7 +391,7 @@ double surf_solve(void) double next_event_date = -1.0; double model_next_action_end = -1.0; double value = -1.0; - surf_model_object_t model_obj = NULL; + surf_resource_t resource = NULL; surf_model_t model = NULL; tmgr_trace_event_t event = NULL; unsigned int iter; @@ -504,10 +400,10 @@ double surf_solve(void) DEBUG0("Looking for next action end"); xbt_dynar_foreach(model_list, iter, model) { - DEBUG1("Running for Resource [%s]", model->common_public->name); - model_next_action_end = model->common_private->share_resources(NOW); + DEBUG1("Running for Resource [%s]", model->name); + model_next_action_end = model->model_private->share_resources(NOW); DEBUG2("Resource [%s] : next action end = %f", - model->common_public->name, model_next_action_end); + model->name, model_next_action_end); if (((min < 0.0) || (model_next_action_end < min)) && (model_next_action_end >= 0.0)) min = model_next_action_end; @@ -525,17 +421,17 @@ double surf_solve(void) DEBUG0("Updating models"); while ((event = tmgr_history_get_next_event_leq(history, next_event_date, - &value, (void **) &model_obj))) { - if (model_obj->model->common_private->resource_used(model_obj)) { + &value, (void **) &resource))) { + if (resource->model->model_private->resource_used(resource)) { min = next_event_date - NOW; DEBUG1 ("This event will modify model state. Next event set to %f", min); } /* update state of model_obj according to new value. Does not touch lmm. It will be modified if needed when updating actions */ - model_obj->model->common_private->update_resource_state(model_obj, - event, value, - NOW + min); + resource->model->model_private->update_resource_state(resource, + event, value, + NOW + min); } } @@ -544,7 +440,7 @@ double surf_solve(void) NOW = NOW + min; xbt_dynar_foreach(model_list, iter, model) { - model->common_private->update_actions_state(NOW, min); + model->model_private->update_actions_state(NOW, min); } return min;