-/* if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
-/* if(((surf_action_lmm_t)action)->variable) { */
-/* lmm_variable_disable(cpu_im_maxmin_system, ((surf_action_lmm_t)action)->variable); */
-/* ((surf_action_lmm_t)action)->variable = NULL; */
-/* } */
-
- surf_action_state_set(action, state);
- return;
-}
-
-static void cpu_im_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));
-#ifdef HAVE_TRACING
- if (TRACE_is_enabled()) {
- TRACE_surf_host_set_utilization(cpu->generic_resource.name,
- action->
- generic_lmm_action.generic_action.
- data, (surf_action_t) action,
- lmm_variable_getvalue
- (GENERIC_LMM_ACTION
- (action).variable),
- cpu->last_update,
- now - cpu->last_update);
- }
-#endif
- XBT_DEBUG("Update action(%p) remains %lf", action,
- GENERIC_ACTION(action).remains);
- }
- }
- cpu->last_update = now;
-}
-
-static double cpu_im_share_resources(double now)
-{
- surf_action_cpu_Cas01_im_t action;
- double min;
- double value;
- cpu_Cas01_im_t cpu, cpu_next;
-
- xbt_swag_foreach(cpu, cpu_im_modified_cpu)
- cpu_im_update_remains(cpu, now);
-
- lmm_solve(cpu_im_maxmin_system);
-
- xbt_swag_foreach_safe(cpu, cpu_next, cpu_im_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) {
- if (GENERIC_ACTION(action).remains > 0) {
- value = GENERIC_ACTION(action).remains / value;
- min = now + value;
- } else {
- value = 0.0;
- min = now;
- }
- }
-
- 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_im_t heap_act =
- xbt_heap_remove(cpu_im_action_heap, action->index_heap);
- if (heap_act != action)
- DIE_IMPOSSIBLE;
- }
- if (min != -1) {
- xbt_heap_push(cpu_im_action_heap, action, min);
- XBT_DEBUG("Insert at heap action(%p) min %lf", action, min);
- }
- }
- xbt_swag_remove(cpu, cpu_im_modified_cpu);
- }
- return xbt_heap_size(cpu_im_action_heap) >
- 0 ? xbt_heap_maxkey(cpu_im_action_heap) - now : -1;