- return lmm_constraint_used(cpu_maxmin_system,
- ((cpu_Cas01_t) resource)->constraint);
-}
-
-static int cpu_action_unref(surf_action_t action)
-{
- action->refcount--;
- if (!action->refcount) {
- xbt_swag_remove(action, action->state_set);
- if (((surf_action_lmm_t) action)->variable)
- lmm_variable_free(cpu_maxmin_system,
- ((surf_action_lmm_t) action)->variable);
- if (cpu_update_mechanism == UM_LAZY) {
- /* remove from heap */
- heap_remove((surf_action_cpu_Cas01_t) action);
- xbt_swag_remove(action, cpu_modified_set);
- }
-#ifdef HAVE_TRACING
- xbt_free(action->category);
-#endif
- surf_action_free(&action);
- return 1;
- }
- return 0;
-}
-
-static void cpu_action_cancel(surf_action_t action)
-{
- surf_action_state_set(action, SURF_ACTION_FAILED);
- if (cpu_update_mechanism == UM_LAZY) {
- xbt_swag_remove(action, cpu_modified_set);
- heap_remove((surf_action_cpu_Cas01_t) action);
- }
- return;
-}
-
-static void cpu_action_state_set(surf_action_t action,
- e_surf_action_state_t state)
-{
-/* if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
-/* if(((surf_action_lmm_t)action)->variable) { */
-/* lmm_variable_disable(cpu_maxmin_system, ((surf_action_lmm_t)action)->variable); */
-/* ((surf_action_lmm_t)action)->variable = NULL; */
-/* } */
-
- surf_action_state_set(action, state);
- return;
-}
-
-static void update_action_remaining_lazy(double now)
-{
- surf_action_cpu_Cas01_t action;
- double delta = 0.0;
-
- xbt_swag_foreach(action, cpu_modified_set) {
- if (GENERIC_ACTION(action).state_set !=
- surf_cpu_model->states.running_action_set)
- continue; // FIXME useless ????
-
- /* bogus priority, skip it */
- if (GENERIC_ACTION(action).priority <= 0)
- continue;
-
- delta = now - GENERIC_LMM_ACTION(action).last_update;
- if (GENERIC_ACTION(action).remains > 0) {
-
- double_update(&(GENERIC_ACTION(action).remains),
- lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable) * delta);
-
-#ifdef HAVE_TRACING
- if (TRACE_is_enabled()) {
- cpu_Cas01_t cpu =
- lmm_constraint_id(lmm_get_cnst_from_var
- (cpu_maxmin_system,
- GENERIC_LMM_ACTION(action).variable, 0));
- TRACE_surf_host_set_utilization(cpu->generic_resource.name,
- ((surf_action_t)action)->category,
- lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable),
- GENERIC_LMM_ACTION(action).last_update,
- now - GENERIC_LMM_ACTION(action).last_update);
- }
-#endif
- XBT_DEBUG("Update action(%p) remains %lf", action,
- GENERIC_ACTION(action).remains);
- }
- GENERIC_LMM_ACTION(action).last_update = now;
- }