X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f7f7d40b071a8c28f2582c39bf599e32802580eb..b84bad24cc0d403e9773384376ecff7d360f8379:/src/surf/network.c diff --git a/src/surf/network.c b/src/surf/network.c index 4b828cab84..c5b61f6a68 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -15,7 +15,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf, surf_model_t surf_network_model = NULL; static lmm_system_t network_maxmin_system = NULL; static void (*network_solve) (lmm_system_t) = NULL; -xbt_dict_t link_set = NULL; double latency_factor = 1.0; /* default value */ double bandwidth_factor = 1.0; /* default value */ @@ -26,11 +25,6 @@ int host_count = 0; double sg_tcp_gamma = 0.0; -static void link_free(void *nw_link) -{ - xbt_dict_free(&(((link_CM02_t) nw_link)->properties)); - surf_resource_free(nw_link); -} static link_CM02_t link_new(char *name, double bw_initial, @@ -44,11 +38,12 @@ static link_CM02_t link_new(char *name, policy, xbt_dict_t properties) { link_CM02_t nw_link = xbt_new0(s_link_CM02_t, 1); - xbt_assert1(!xbt_dict_get_or_null(link_set, name), + xbt_assert1(!xbt_dict_get_or_null(surf_network_model->resource_set, name), "Link '%s' declared several times in the platform file.", name); nw_link->generic_resource.model = surf_network_model; nw_link->generic_resource.name = name; + current_property_set = nw_link->generic_resource.properties = properties; nw_link->bw_current = bw_initial; if (bw_trace) nw_link->bw_event = @@ -69,11 +64,7 @@ static link_CM02_t link_new(char *name, if (policy == SURF_LINK_FATPIPE) lmm_constraint_shared(nw_link->constraint); - nw_link->properties = properties; - - current_property_set = properties; - - xbt_dict_set(link_set, name, nw_link, link_free); + xbt_dict_set(surf_network_model->resource_set, name, nw_link, surf_resource_free); return nw_link; } @@ -130,7 +121,7 @@ static void add_traces(void) /* connect all traces relative to network */ xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) { tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name); - link_CM02_t link = xbt_dict_get_or_null(link_set, elm); + link_CM02_t link = xbt_dict_get_or_null(surf_network_model->resource_set, elm); xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined", trace_name, elm); @@ -142,7 +133,7 @@ static void add_traces(void) xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) { tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name); - link_CM02_t link = xbt_dict_get_or_null(link_set, elm); + link_CM02_t link = xbt_dict_get_or_null(surf_network_model->resource_set, elm); xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined", trace_name, elm); @@ -154,7 +145,7 @@ static void add_traces(void) xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) { tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name); - link_CM02_t link = xbt_dict_get_or_null(link_set, elm); + link_CM02_t link = xbt_dict_get_or_null(surf_network_model->resource_set, elm); xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined", trace_name, elm); @@ -373,28 +364,15 @@ static surf_action_t communicate(const char *src_name, const char *dst_name,int "You're trying to send data from %s to %s but there is no connection between these two hosts.", src_name, dst_name); - action = xbt_new0(s_surf_action_network_CM02_t, 1); - - action->generic_action.refcount = 1; - action->generic_action.cost = size; - action->generic_action.remains = size; - action->generic_action.max_duration = NO_MAX_DURATION; - action->generic_action.start = surf_get_clock(); - action->generic_action.finish = -1.0; - action->generic_action.model_type = surf_network_model; - action->suspended = 0; /* Should be useless because of the - calloc but it seems to help valgrind... */ - action->generic_action.state_set = - surf_network_model->states.running_action_set; - link_CM02_t link; + int failed=0; xbt_dynar_foreach(route,i,link) { if (link->state_current == SURF_LINK_OFF) { - action->generic_action.state_set = - surf_network_model->states.failed_action_set; + failed = 1; break; } } + action = surf_action_new(sizeof(s_surf_action_network_CM02_t),size,surf_network_model,failed); xbt_swag_insert(action, action->generic_action.state_set); action->rate = rate; @@ -465,11 +443,6 @@ static int link_shared(const void *link) return lmm_constraint_is_shared(((link_CM02_t) link)->constraint); } -static xbt_dict_t get_properties(void *link) -{ - return ((link_CM02_t) link)->properties; -} - static void action_suspend(surf_action_t action) { ((surf_action_network_CM02_t) action)->suspended = 1; @@ -501,8 +474,6 @@ static void action_set_max_duration(surf_action_t action, double duration) static void finalize(void) { - xbt_dict_free(&link_set); - surf_model_exit(surf_network_model); surf_network_model = NULL; @@ -514,7 +485,6 @@ static void finalize(void) static void surf_network_model_init_internal(void) { - link_set = xbt_dict_new(); surf_network_model = surf_model_init(); surf_network_model->name = "network"; @@ -541,12 +511,10 @@ static void surf_network_model_init_internal(void) surf_network_model->extension.network.get_link_latency = get_link_latency; surf_network_model->extension.network.link_shared = link_shared; - surf_network_model->get_properties = get_properties; - if (!network_maxmin_system) network_maxmin_system = lmm_system_new(); - routing_model_full_create(sizeof(link_CM02_t), + routing_model_create(sizeof(link_CM02_t), link_new(xbt_strdup("__loopback__"), 498000000, NULL, 0.000015, NULL, SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL));