- if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION)
- && (min == -1
- || GENERIC_ACTION(action).start +
- GENERIC_ACTION(action).max_duration < min))
- min =
- GENERIC_ACTION(action).start +
- GENERIC_ACTION(action).max_duration;
-
- XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
- GENERIC_ACTION(action).start, now + value,
- GENERIC_ACTION(action).max_duration);
-
- if (action->index_heap >= 0) {
- surf_action_cpu_Cas01_t heap_act =
- xbt_heap_remove(cpu_action_heap, action->index_heap);
- if (heap_act != action)
- DIE_IMPOSSIBLE;
- }
- if (min != -1) {
- xbt_heap_push(cpu_action_heap, action, min);
- XBT_DEBUG("Insert at heap action(%p) min %lf", action, min);
+ xbt_swag_foreach(action, cpu_modified_set) {
+ int max_dur_flag = 0;
+
+ 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) {
+ if (GENERIC_ACTION(action).remains > 0) {
+ value = GENERIC_ACTION(action).remains / value;
+ min = now + value;
+ } else {
+ value = 0.0;
+ min = now;