Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add tests to skip actions that aren't running or have priority = 0.
authordonassbr <donassbr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 4 Nov 2009 12:13:26 +0000 (12:13 +0000)
committerdonassbr <donassbr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 4 Nov 2009 12:13:26 +0000 (12:13 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6828 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/surf/cpu_im.c

index e572147..f6c0be8 100644 (file)
@@ -202,13 +202,22 @@ static void cpu_update_remains(cpu_Cas01_im_t cpu, double now)
 {
   surf_action_cpu_Cas01_im_t action;
 
+  if (cpu->last_update >= now)
+    return;
   xbt_swag_foreach(action, cpu->action_set) {
+    if (GENERIC_ACTION(action).state_set !=
+        surf_cpu_model->states.running_action_set)
+      continue;
+
+    /* bogus priority, skip it */
+    if (GENERIC_ACTION(action).priority <= 0)
+      continue;
+
     if (GENERIC_ACTION(action).remains > 0) {
       double_update(&(GENERIC_ACTION(action).remains),
                     lmm_variable_getvalue(GENERIC_LMM_ACTION
                                           (action).variable) * (now -
-                                                                cpu->
-                                                                last_update));
+                                                                cpu->last_update));
       DEBUG2("Update action(%p) remains %lf", action,
              GENERIC_ACTION(action).remains);
     }
@@ -230,6 +239,14 @@ static double share_resources(double now)
 
   xbt_swag_foreach_safe(cpu, cpu_next, modified_cpu) {
     xbt_swag_foreach(action, cpu->action_set) {
+      if (GENERIC_ACTION(action).state_set !=
+          surf_cpu_model->states.running_action_set)
+        continue;
+
+      /* bogus priority, skip it */
+      if (GENERIC_ACTION(action).priority <= 0)
+        continue;
+
       min = -1;
       value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
       if (value > 0) {
@@ -281,7 +298,7 @@ static void update_actions_state(double now, double delta)
     /* set the remains to 0 due to precision problems when updating the remaining amount */
     GENERIC_ACTION(action).remains = 0;
     cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
-    xbt_swag_insert(action->cpu, modified_cpu);
+    cpu_update_remains(action->cpu, surf_get_clock());
   }
   return;
 }