return card->id;
}
-static void route_new(int src_id, int dst_id, char **links, int nb_link)
+static void route_new(int src_id, int dst_id, network_link_DASSF_t *link_list, int nb_link)
{
- network_link_DASSF_t *link_list = NULL;
- int i;
-
ROUTE_SIZE(src_id, dst_id) = nb_link;
- link_list = (ROUTE(src_id, dst_id) = xbt_new0(network_link_DASSF_t, nb_link));
- for (i = 0; i < nb_link; i++) {
- link_list[i] = xbt_dict_get_or_null(network_link_set, links[i]);
- free(links[i]);
- }
- free(links);
+ ROUTE(src_id, dst_id) = link_list = xbt_realloc(link_list, sizeof(network_link_DASSF_t) * nb_link);
}
static void parse_network_link(void)
lat_initial, lat_trace, state_initial, state_trace);
}
-static int nb_link = 0;
-static char **link_name = NULL;
+static int nb_link;
+static int link_list_capacity;
+static network_link_DASSF_t *link_list = NULL;
static int src_id = -1;
static int dst_id = -1;
src_id = network_card_new(A_surfxml_route_src);
dst_id = network_card_new(A_surfxml_route_dst);
nb_link = 0;
- link_name = NULL;
+ link_list_capacity = 20;
+ link_list = xbt_new(network_link_DASSF_t, link_list_capacity);
}
static void parse_route_elem(void)
{
- nb_link++;
- link_name = xbt_realloc(link_name, (nb_link) * sizeof(char *));
- link_name[(nb_link) - 1] = xbt_strdup(A_surfxml_route_element_name);
+ if (nb_link == link_list_capacity) {
+ link_list_capacity *= 2;
+ link_list = xbt_realloc(link_list, link_list_capacity * sizeof(network_link_DASSF_t));
+ }
+ link_list[nb_link++] = xbt_dict_get_or_null(network_link_set, A_surfxml_route_element_name);
}
static void parse_route_set_route(void)
{
- route_new(src_id, dst_id, link_name, nb_link);
+ route_new(src_id, dst_id, link_list, nb_link);
}
static void parse_file(const char *file)
return;
}
+/* I nothing more happens, return the date at which the first action that will terminate does terminate */
+/* This returns the time for the first NETWORK action to complete */
+/* It would be nice to store this minimum somewhere so that the next function can
+ figure out whether the min comes from the network or from something else */
static double share_resources(double now)
{
s_surf_action_network_DASSF_t s_action;
return min;
}
+/* delta: by how many time units the simulation must advance */
+/* In this function: change the state of actions that terminate */
+/* The delta may not come from the network, and thus may be different (smaller)
+ than the one returned by the function above */
+/* If the delta is a network-caused min, then do not emulate any timer in the
+ network simulation, otherwise fake a timer somehow to advance the simulation of min seconds */
+
static void update_actions_state(double now, double delta)
{
double deltap = 0.0;
deltap = delta;
if (action->latency > 0) {
if (action->latency > deltap) {
- surf_double_update(&(action->latency),deltap);
+ double_update(&(action->latency),deltap);
deltap = 0.0;
} else {
- surf_double_update(&(deltap), action->latency);
+ double_update(&(deltap), action->latency);
action->latency = 0.0;
}
if ((action->latency == 0.0) && !(action->suspended))
lmm_update_variable_weight(maxmin_system, action->variable, 1.0);
}
- surf_double_update(&(action->generic_action.remains),
+ double_update(&(action->generic_action.remains),
lmm_variable_getvalue(action->variable) * deltap);
if (action->generic_action.max_duration != NO_MAX_DURATION)
- surf_double_update(&(action->generic_action.max_duration), delta);
+ double_update(&(action->generic_action.max_duration), delta);
/* if(action->generic_action.remains<.00001) action->generic_action.remains=0; */
action->generic_action.finish = surf_get_clock();
action_change_state((surf_action_t) action, SURF_ACTION_DONE);
} else { /* Need to check that none of the resource has failed */
+ /* to ignore for now */
lmm_constraint_t cnst = NULL;
int i = 0;
network_link_DASSF_t nw_link = NULL;
return;
}
+/* Called only when there is a change in trace: Useless in packet-level simulation */
static void update_resource_state(void *id,
tmgr_trace_event_t event_type,
double value)