Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use the rate variable... (thanks Fred for noticing it).
[simgrid.git] / src / surf / workstation_ptask_L07.c
index 34468c7..989379e 100644 (file)
@@ -144,15 +144,15 @@ static xbt_dict_t get_properties(void *r) {
 
 static void action_use(surf_action_t action)
 {
-  action->using++;
+  action->refcount ++;
   return;
 }
 
 static int action_free(surf_action_t action)
 {
-  action->using--;
+  action->refcount --;
 
-  if (!action->using) {
+  if (!action->refcount ) {
     xbt_swag_remove(action, action->state_set);
     if (((surf_action_workstation_L07_t) action)->variable)
       lmm_variable_free(ptask_maxmin_system,
@@ -521,7 +521,7 @@ static surf_action_t execute_parallel_task(int workstation_nb,
   action = xbt_new0(s_surf_action_workstation_L07_t, 1);
   DEBUG3("Creating a parallel task (%p) with %d cpus and %d links.",
         action, workstation_nb, nb_link);
-  action->generic_action.using = 1;
+  action->generic_action.refcount  = 1;
   action->generic_action.cost = amount;
   action->generic_action.remains = amount;
   action->generic_action.max_duration = NO_MAX_DURATION;
@@ -542,14 +542,10 @@ static surf_action_t execute_parallel_task(int workstation_nb,
   xbt_swag_insert(action, action->generic_action.state_set);
   action->rate = rate;
 
-  if (action->rate > 0)
-    action->variable =
-       lmm_variable_new(ptask_maxmin_system, action, 1.0, -1.0,
-                        workstation_nb + nb_link);
-  else
-    action->variable =
-       lmm_variable_new(ptask_maxmin_system, action, 1.0, action->rate,
-                        workstation_nb + nb_link);
+  action->variable =
+    lmm_variable_new(ptask_maxmin_system, action, 1.0, 
+                    (action->rate>0)?action->rate:-1.0,
+                    workstation_nb + nb_link);
 
   if (action->latency > 0) 
     lmm_update_variable_weight(ptask_maxmin_system,action->variable,0.0);
@@ -665,6 +661,10 @@ static double get_link_latency(const void *link)
   return ((link_L07_t) link)->lat_current;
 }
 
+static int link_shared(const void *link)
+{
+  return lmm_constraint_is_shared(((link_L07_t) link)->constraint);
+}
 
 /**************************************/
 /*** Resource Creation & Destruction **/
@@ -673,6 +673,7 @@ static double get_link_latency(const void *link)
 static void cpu_free(void *cpu)
 {
   free(((cpu_L07_t) cpu)->name);
+  xbt_dict_free(&(((cpu_L07_t)cpu)->properties));
   free(cpu);
 }
 
@@ -751,6 +752,7 @@ static void parse_cpu_init(void)
 static void link_free(void *nw_link)
 {
   free(((link_L07_t) nw_link)->name);
+  xbt_dict_free(&(((link_L07_t)nw_link)->properties));
   free(nw_link);
 }
 
@@ -1121,6 +1123,8 @@ static void model_init_internal(void)
       get_link_bandwidth;
   surf_workstation_model->extension_public->get_link_latency =
       get_link_latency;
+  surf_workstation_model->extension_public->link_shared =
+      link_shared;
 
   surf_workstation_model->common_public->get_properties = get_properties;