Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Incredible bug fix in function lmm_get_var_from_cnst with bad consequences on trace...
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 20 May 2008 09:56:47 +0000 (09:56 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 20 May 2008 09:56:47 +0000 (09:56 +0000)
This function could not work so I had to change the prototype and update parts of the code that relied on it.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5443 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/include/surf/maxmin.h
src/surf/maxmin.c
src/surf/maxmin_private.h
src/surf/network.c
src/surf/workstation_ptask_L07.c

index b38ed7b..0ebd6a4 100644 (file)
@@ -22,6 +22,7 @@ static XBT_INLINE int double_positive(double value)
   return (value>MAXMIN_PRECISION);
 }
 
+typedef struct lmm_element *lmm_element_t;
 typedef struct lmm_variable *lmm_variable_t;
 typedef struct lmm_constraint *lmm_constraint_t;
 typedef struct lmm_system *lmm_system_t;
@@ -54,7 +55,7 @@ lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
 int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var);
 lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
                                     lmm_constraint_t cnst,
-                                    lmm_variable_t * var);
+                                    lmm_element_t * elem);
 
 lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys);
 lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys, lmm_constraint_t cnst);
index 405a409..c240511 100644 (file)
@@ -274,13 +274,16 @@ int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var)
 
 lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
                                     lmm_constraint_t cnst,
-                                    lmm_variable_t * var)
+                                    lmm_element_t * elem)
 {
-  if (!(*var))
-    xbt_swag_getFirst(&(cnst->element_set));
+  if (!(*elem))
+    *elem = xbt_swag_getFirst(&(cnst->element_set));
   else
-    *var = xbt_swag_getNext(*var, cnst->element_set.offset);
-  return *var;
+    *elem = xbt_swag_getNext(*elem, cnst->element_set.offset);
+  if(*elem)
+    return (*elem)->variable;
+  else 
+    return NULL;
 }
 
 void *lmm_constraint_id(lmm_constraint_t cnst)
index 1798472..cfdf61b 100644 (file)
@@ -20,7 +20,7 @@ typedef struct lmm_element {
   lmm_constraint_t constraint;
   lmm_variable_t variable;
   double value;
-} s_lmm_element_t, *lmm_element_t;
+} s_lmm_element_t;
 #define make_elem_active(elem) xbt_swag_insert_at_head(elem,&(elem->constraint->active_element_set))
 #define make_elem_inactive(elem) xbt_swag_remove(elem,&(elem->constraint->active_element_set))
 
index c678242..840ad3e 100644 (file)
@@ -472,11 +472,12 @@ static void update_resource_state(void *id,
   } else if (event_type == nw_link->lat_event) {
     double delta = value - nw_link->lat_current;
     lmm_variable_t var = NULL;
+    lmm_element_t elem = NULL;
     surf_action_network_CM02_t action = NULL;
 
     nw_link->lat_current = value;
-    while (lmm_get_var_from_cnst
-          (network_maxmin_system, nw_link->constraint, &var)) {
+    while (var= lmm_get_var_from_cnst
+          (network_maxmin_system, nw_link->constraint, &elem)) {
       action = lmm_variable_id(var);
       action->lat_current += delta;
       if (action->rate < 0)
index de44851..6c68352 100644 (file)
@@ -375,10 +375,11 @@ static void update_resource_state(void *id,
     } else if (event_type == nw_link->lat_event) {
       lmm_variable_t var = NULL;
       surf_action_workstation_L07_t action = NULL;
+      lmm_element_t elem = NULL;
 
       nw_link->lat_current = value;
-      while (lmm_get_var_from_cnst
-            (ptask_maxmin_system, nw_link->constraint, &var)) {
+      while (var = lmm_get_var_from_cnst
+            (ptask_maxmin_system, nw_link->constraint, &elem)) {
        
 
        action = lmm_variable_id(var);