+ 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.model_type =
+ (surf_model_t) surf_cpu_model;
+ action->suspended = 0; /* Should be useless because of the
+ calloc but it seems to help valgrind... */
+
+ if (CPU->state_current == SURF_CPU_ON)
+ action->generic_action.state_set =
+ surf_cpu_model->common_public->states.running_action_set;
+ else
+ action->generic_action.state_set =
+ surf_cpu_model->common_public->states.failed_action_set;
+ /* Insert at the head by default. This convention is used to speed
+ up update_resource_state */
+ xbt_swag_insert_at_head(action, action->generic_action.state_set);
+
+ action->variable = lmm_variable_new(cpu_maxmin_system, action,
+ action->generic_action.priority,
+ -1.0, 1);
+ lmm_expand(cpu_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_swag_t action_set = NULL;
+ if (duration>0)
+ duration=MAX(duration,MAXMIN_PRECISION);
+
+ 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;
+ action->suspended = 2;
+ if(duration == NO_MAX_DURATION) {
+ /* Move to the *end* of the corresponding action set. This convention
+ is used to speed up update_resource_state */
+ action_set = action->generic_action.state_set;
+ xbt_swag_remove(action, action_set);
+ xbt_swag_insert(action, action_set);
+ }
+
+ lmm_update_variable_weight(cpu_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);
+ if (((surf_action_cpu_Cas01_t) action)->suspended != 2) {
+ lmm_update_variable_weight(cpu_maxmin_system,
+ ((surf_action_cpu_Cas01_t) action)->
+ variable, 0.0);
+ ((surf_action_cpu_Cas01_t) action)->suspended = 1;
+ }
+ XBT_OUT;
+}
+
+static void action_resume(surf_action_t action)
+{
+ XBT_IN1("(%p)", action);
+ if (((surf_action_cpu_Cas01_t) action)->suspended != 2) {
+ lmm_update_variable_weight(cpu_maxmin_system,
+ ((surf_action_cpu_Cas01_t) action)->
+ variable, action->priority);
+ ((surf_action_cpu_Cas01_t) action)->suspended = 0;
+ }
+ XBT_OUT;
+}
+
+static int action_is_suspended(surf_action_t action)
+{
+ return (((surf_action_cpu_Cas01_t) action)->suspended == 1);
+}
+
+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;
+ lmm_update_variable_weight(cpu_maxmin_system, ((surf_action_cpu_Cas01_t) action)->variable, priority);
+
+ XBT_OUT;
+}
+
+static e_surf_cpu_state_t get_state(void *cpu)
+{
+ return ((cpu_Cas01_t) cpu)->state_current;
+}
+
+static double get_speed(void *cpu, double load)
+{
+ return load * (((cpu_Cas01_t) cpu)->power_scale);