- 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 */
- xbt_heap_remove(cpu_action_heap,
- ((surf_action_cpu_Cas01_t) action)->index_heap);
- xbt_swag_remove(action,
- ((cpu_Cas01_t) ACTION_GET_CPU(action))->action_set);
- xbt_swag_insert(ACTION_GET_CPU(action), cpu_modified_cpu);
- }
-#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_heap_remove(cpu_action_heap,
- ((surf_action_cpu_Cas01_t) action)->index_heap);
- xbt_swag_remove(action,
- ((cpu_Cas01_t) ACTION_GET_CPU(action))->action_set);
- }
- return;
-}
-
-static void cpu_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 cpu_update_remains(cpu_Cas01_t cpu, double now)
-{
- 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;