"Logging specific to the SURF CPU module");
surf_cpu_resource_t surf_cpu_resource = NULL;
+lmm_system_t cpu_maxmin_system = NULL;
xbt_dict_t cpu_set = NULL;
tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
cpu->constraint =
- lmm_constraint_new(maxmin_system, cpu,
+ lmm_constraint_new(cpu_maxmin_system, cpu,
cpu->power_current * cpu->power_scale);
xbt_dict_set(cpu_set, name, cpu, cpu_free);
static int resource_used(void *resource_id)
{
- return lmm_constraint_used(maxmin_system,
+ return lmm_constraint_used(cpu_maxmin_system,
((cpu_Cas01_t) resource_id)->constraint);
}
if(!action->using) {
xbt_swag_remove(action, action->state_set);
if(((surf_action_cpu_Cas01_t)action)->variable)
- lmm_variable_free(maxmin_system, ((surf_action_cpu_Cas01_t)action)->variable);
+ lmm_variable_free(cpu_maxmin_system, ((surf_action_cpu_Cas01_t)action)->variable);
free(action);
return 1;
}
{
/* if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
/* if(((surf_action_cpu_Cas01_t)action)->variable) { */
-/* lmm_variable_disable(maxmin_system, ((surf_action_cpu_Cas01_t)action)->variable); */
+/* lmm_variable_disable(cpu_maxmin_system, ((surf_action_cpu_Cas01_t)action)->variable); */
/* ((surf_action_cpu_Cas01_t)action)->variable = NULL; */
/* } */
static double share_resources(double now)
{
s_surf_action_cpu_Cas01_t action;
- return generic_maxmin_share_resources(surf_cpu_resource->common_public->
- states.running_action_set,
- xbt_swag_offset(action, variable));
+ return generic_maxmin_share_resources2(surf_cpu_resource->common_public->
+ states.running_action_set,
+ xbt_swag_offset(action, variable),
+ cpu_maxmin_system, lmm_solve);
}
static void update_actions_state(double now, double delta)
*/
xbt_swag_foreach_safe(action, next_action, running_actions) {
- surf_double_update(&(action->generic_action.remains),
+ double_update(&(action->generic_action.remains),
lmm_variable_getvalue(action->variable) * delta);
if (action->generic_action.max_duration != NO_MAX_DURATION)
- surf_double_update(&(action->generic_action.max_duration), delta);
+ double_update(&(action->generic_action.max_duration), delta);
if ((action->generic_action.remains <= 0) &&
(lmm_get_variable_weight(action->variable)>0)) {
action->generic_action.finish = surf_get_clock();
cpu_Cas01_t cpu = NULL;
while ((cnst =
- lmm_get_cnst_from_var(maxmin_system, action->variable,
+ lmm_get_cnst_from_var(cpu_maxmin_system, action->variable,
i++))) {
cpu = lmm_constraint_id(cnst);
if (cpu->state_current == SURF_CPU_OFF) {
if (event_type == cpu->power_event) {
cpu->power_current = value;
- lmm_update_constraint_bound(maxmin_system, cpu->constraint,
+ lmm_update_constraint_bound(cpu_maxmin_system, cpu->constraint,
cpu->power_current * cpu->power_scale);
} else if (event_type == cpu->state_event) {
if (value > 0)
action->generic_action.finish = -1.0;
action->generic_action.resource_type =
(surf_resource_t) surf_cpu_resource;
+ 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_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->variable = lmm_variable_new(cpu_maxmin_system, action,
action->generic_action.priority, -1.0, 1);
- lmm_expand(maxmin_system, CPU->constraint, action->variable,
+ lmm_expand(cpu_maxmin_system, CPU->constraint, action->variable,
1.0);
XBT_OUT;
return (surf_action_t) action;
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);
+ action->suspended = 2;
+ 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);
- lmm_update_variable_weight(maxmin_system,
- ((surf_action_cpu_Cas01_t) action)->variable, 0.0);
+ 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);
- lmm_update_variable_weight(maxmin_system,
- ((surf_action_cpu_Cas01_t) action)->variable,
- action->priority);
+ 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 (lmm_get_variable_weight(((surf_action_cpu_Cas01_t) action)->variable) == 0.0);
+ return (((surf_action_cpu_Cas01_t) action)->suspended==1);
}
static void action_set_max_duration(surf_action_t action, double duration)
surf_cpu_resource->common_public->get_resource_name = get_resource_name;
surf_cpu_resource->common_public->action_get_state =
surf_action_get_state;
+ surf_cpu_resource->common_public->action_get_start_time =
+ surf_action_get_start_time;
+ surf_cpu_resource->common_public->action_get_finish_time =
+ surf_action_get_finish_time;
surf_cpu_resource->common_public->action_free = action_free;
surf_cpu_resource->common_public->action_use = action_use;
surf_cpu_resource->common_public->action_cancel = action_cancel;
cpu_set = xbt_dict_new();
- xbt_assert0(maxmin_system, "surf_init has to be called first!");
+ if(!cpu_maxmin_system)
+ cpu_maxmin_system = lmm_system_new();
}
/*********************************************************************/