Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ptask_L07 can now do execute and communicate via execute_parallel_task
[simgrid.git] / src / surf / network_dassf.c
index 3d31515..ec0b99b 100644 (file)
@@ -86,18 +86,10 @@ static int network_card_new(const char *card_name)
   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)
@@ -130,8 +122,8 @@ static void parse_network_link(void)
 }
 
 static int nb_link;
-static int link_name_capacity;
-static char **link_name = NULL;
+static int link_list_capacity;
+static network_link_DASSF_t *link_list = NULL;
 static int src_id = -1;
 static int dst_id = -1;
 
@@ -140,22 +132,22 @@ static void parse_route_set_endpoints(void)
   src_id = network_card_new(A_surfxml_route_src);
   dst_id = network_card_new(A_surfxml_route_dst);
   nb_link = 0;
-  link_name_capacity = 16;
-  link_name = xbt_new(char*, link_name_capacity);
+  link_list_capacity = 20;
+  link_list = xbt_new(network_link_DASSF_t, link_list_capacity);
 }
 
 static void parse_route_elem(void)
 {
-  if (nb_link == link_name_capacity) {
-    link_name_capacity *= 2;
-    link_name = xbt_realloc(link_name, (link_name_capacity) * sizeof(char *));
+  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_name[nb_link++] = xbt_strdup(A_surfxml_route_element_name);
+  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)
@@ -237,6 +229,10 @@ static void action_change_state(surf_action_t action,
   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;
@@ -255,6 +251,13 @@ static double share_resources(double now)
   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;
@@ -271,19 +274,19 @@ static void update_actions_state(double now, double delta)
     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; */
 
@@ -295,6 +298,7 @@ static void update_actions_state(double now, double delta)
       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;
@@ -315,6 +319,7 @@ static void update_actions_state(double now, double delta)
   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)