+ cpu_Cas01_t cpu = id;
+
+ if (event_type == cpu->power_event) {
+ cpu->power_current = value;
+ lmm_update_constraint_bound(maxmin_system, cpu->constraint,
+ cpu->power_current * cpu->power_scale);
+ } else if (event_type == cpu->state_event) {
+ if (value > 0)
+ cpu->state_current = SURF_CPU_ON;
+ else
+ cpu->state_current = SURF_CPU_OFF;
+ } else {
+ CRITICAL0("Unknown event ! \n");
+ xbt_abort();
+ }
+
+ return;
+}
+
+static surf_action_t execute(void *cpu, double size)
+{
+ surf_action_cpu_Cas01_t action = NULL;
+ cpu_Cas01_t CPU = cpu;
+
+ XBT_IN2("(%s,%g)",CPU->name,size);
+ action = xbt_new0(s_surf_action_cpu_Cas01_t, 1);
+
+ action->generic_action.using = 1;
+ action->generic_action.cost = size;
+ action->generic_action.remains = size;
+ action->generic_action.priority = 1.0;
+ action->generic_action.max_duration = NO_MAX_DURATION;
+ action->generic_action.start = surf_get_clock();
+ action->generic_action.finish = -1.0;
+ action->generic_action.resource_type =
+ (surf_resource_t) surf_cpu_resource;
+
+ if (CPU->state_current == SURF_CPU_ON)
+ action->generic_action.state_set =
+ surf_cpu_resource->common_public->states.running_action_set;
+ else
+ action->generic_action.state_set =
+ surf_cpu_resource->common_public->states.failed_action_set;
+ xbt_swag_insert(action, action->generic_action.state_set);
+
+ action->variable = lmm_variable_new(maxmin_system, action,
+ action->generic_action.priority, -1.0, 1);
+ lmm_expand(maxmin_system, CPU->constraint, action->variable,
+ 1.0);
+ XBT_OUT;
+ return (surf_action_t) action;
+}
+
+static surf_action_t action_sleep(void *cpu, double duration)
+{
+ surf_action_cpu_Cas01_t action = NULL;
+
+ XBT_IN2("(%s,%g)",((cpu_Cas01_t)cpu)->name,duration);
+ action = (surf_action_cpu_Cas01_t) execute(cpu, 1.0);
+ action->generic_action.max_duration = duration;
+ lmm_update_variable_weight(maxmin_system, action->variable, 0.0);
+ XBT_OUT;
+ return (surf_action_t) action;
+}
+
+static void action_suspend(surf_action_t action)
+{
+ XBT_IN1("(%p)",action);
+ lmm_update_variable_weight(maxmin_system,
+ ((surf_action_cpu_Cas01_t) action)->variable, 0.0);
+ XBT_OUT;
+}
+
+static void action_resume(surf_action_t action)
+{
+ XBT_IN1("(%p)",action);
+ lmm_update_variable_weight(maxmin_system,
+ ((surf_action_cpu_Cas01_t) action)->variable,
+ action->priority);
+ XBT_OUT;
+}
+
+static int action_is_suspended(surf_action_t action)
+{
+ return (lmm_get_variable_weight(((surf_action_cpu_Cas01_t) action)->variable) == 0.0);
+}
+
+static void action_set_max_duration(surf_action_t action, double duration)
+{
+ XBT_IN2("(%p,%g)",action,duration);
+ action->max_duration = duration;
+ XBT_OUT;
+}
+
+static void action_set_priority(surf_action_t action, double priority)
+{
+ XBT_IN2("(%p,%g)",action,priority);
+ action->priority = priority;
+ XBT_OUT;