static void cpu_free(void *cpu)
{
- free(((cpu_Cas01_t) cpu)->name);
xbt_dict_free(&(((cpu_Cas01_t) cpu)->properties));
- free(cpu);
+ surf_resource_free(cpu);
}
static cpu_Cas01_t cpu_new(char *name, double power_scale,
cpu_Cas01_t cpu = xbt_new0(s_cpu_Cas01_t, 1);
xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
"Host '%s' declared several times in the platform file", name);
- cpu->model = surf_cpu_model;
- cpu->name = name;
+ cpu->generic_resource.model = surf_cpu_model;
+ cpu->generic_resource.name = name;
cpu->power_scale = power_scale;
xbt_assert0(cpu->power_scale > 0, "Power has to be >0");
cpu->power_current = power_initial;
surfxml_add_callback(STag_surfxml_host_cb_list, parse_cpu_init);
}
-static const char *get_resource_name(void *resource_id)
-{
- return ((cpu_Cas01_t) resource_id)->name;
-}
-
static int resource_used(void *resource_id)
{
return lmm_constraint_used(cpu_maxmin_system,
static double share_resources(double now)
{
s_surf_action_cpu_Cas01_t action;
- return generic_maxmin_share_resources(surf_cpu_model->
- states.running_action_set,
+ return generic_maxmin_share_resources(surf_cpu_model->states.
+ running_action_set,
xbt_swag_offset(action, variable),
cpu_maxmin_system, lmm_solve);
}
cpu_maxmin_system = NULL;
surf_model_exit(surf_cpu_model);
+ surf_cpu_model = NULL;
xbt_swag_free(running_action_set_that_does_not_need_being_checked);
running_action_set_that_does_not_need_being_checked = NULL;
-
- free(surf_cpu_model);
- surf_cpu_model = NULL;
}
static void surf_cpu_model_init_internal(void)
{
s_surf_action_t action;
- surf_cpu_model = xbt_new0(s_surf_model_t, 1);
-
- surf_model_init(surf_cpu_model);
+ surf_cpu_model = surf_model_init();
running_action_set_that_does_not_need_being_checked =
xbt_swag_new(xbt_swag_offset(action, state_hookup));
- surf_cpu_model->get_resource_name = get_resource_name;
surf_cpu_model->action_get_state = surf_action_get_state;
surf_cpu_model->action_get_start_time = surf_action_get_start_time;
surf_cpu_model->action_get_finish_time = surf_action_get_finish_time;