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 */
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,
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 =
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;
}
/* 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);
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);
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);
"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;
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;
static void finalize(void)
{
- xbt_dict_free(&link_set);
-
surf_model_exit(surf_network_model);
surf_network_model = NULL;
static void surf_network_model_init_internal(void)
{
- link_set = xbt_dict_new();
surf_network_model = surf_model_init();
surf_network_model->name = "network";
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));