- surf_action_cpu_Cas01_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_share_resources_lazy(double now)
-{
- surf_action_cpu_Cas01_t action;
- double min;
- double value;
- cpu_Cas01_t cpu, cpu_next;
-
- xbt_swag_foreach(cpu, cpu_modified_cpu)
- cpu_update_remains(cpu, now);
-
- lmm_solve(cpu_maxmin_system);
-
- xbt_swag_foreach_safe(cpu, cpu_next, cpu_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_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_remove(cpu, cpu_modified_cpu);
- }
- return xbt_heap_size(cpu_action_heap) >
- 0 ? xbt_heap_maxkey(cpu_action_heap) - now : -1;
-}
-
-static double cpu_share_resources_full(double now) {
- surf_action_cpu_Cas01_t action;
- return generic_maxmin_share_resources(surf_cpu_model->states.running_action_set,
- xbt_swag_offset(*action, generic_lmm_action.variable),
- cpu_maxmin_system, lmm_solve);