X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5c20a8cf542cec3ab3f07b9fa431e63754dbbfd6..7e2b05b2e2ec6a745966f800121782a684166f6f:/src/surf/cpu.c?ds=sidebyside diff --git a/src/surf/cpu.c b/src/surf/cpu.c index c2d01b500a..6a9f6e5883 100644 --- a/src/surf/cpu.c +++ b/src/surf/cpu.c @@ -7,7 +7,8 @@ #include "surf_private.h" -typedef s_surf_action_lmm_t s_surf_action_cpu_Cas01_t, *surf_action_cpu_Cas01_t; +typedef s_surf_action_lmm_t s_surf_action_cpu_Cas01_t, + *surf_action_cpu_Cas01_t; typedef struct cpu_Cas01 { s_surf_resource_t generic_resource; @@ -59,7 +60,8 @@ static cpu_Cas01_t cpu_new(char *name, double power_peak, lmm_constraint_new(cpu_maxmin_system, cpu, cpu->power_scale * cpu->power_peak); - xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu, surf_resource_free); + xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu, + surf_resource_free); return cpu; } @@ -130,6 +132,7 @@ static void define_callbacks(const char *file) { surf_parse_reset_parser(); surfxml_add_callback(STag_surfxml_host_cb_list, parse_cpu_init); + surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces_cpu); } static int resource_used(void *resource_id) @@ -159,7 +162,7 @@ static void action_cancel(surf_action_t action) } static void cpu_action_state_set(surf_action_t action, - e_surf_action_state_t state) + e_surf_action_state_t state) { /* if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */ /* if(((surf_action_cpu_Cas01_t)action)->variable) { */ @@ -174,8 +177,8 @@ static void cpu_action_state_set(surf_action_t action, 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); } @@ -215,6 +218,8 @@ static void update_resource_state(void *id, cpu->power_scale = value; lmm_update_constraint_bound(cpu_maxmin_system, cpu->constraint, cpu->power_scale * cpu->power_peak); + if (tmgr_trace_event_free(event_type)) + cpu->power_event = NULL; } else if (event_type == cpu->state_event) { if (value > 0) cpu->state_current = SURF_RESOURCE_ON; @@ -236,6 +241,8 @@ static void update_resource_state(void *id, } } } + if (tmgr_trace_event_free(event_type)) + cpu->state_event = NULL; } else { CRITICAL0("Unknown event ! \n"); xbt_abort(); @@ -249,9 +256,10 @@ 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->generic_resource.name, size); - action = surf_action_new(sizeof(s_surf_action_cpu_Cas01_t),size,surf_cpu_model, - CPU->state_current != SURF_RESOURCE_ON); + XBT_IN2("(%s,%g)", surf_resource_name(CPU), size); + action = + surf_action_new(sizeof(s_surf_action_cpu_Cas01_t), size, surf_cpu_model, + CPU->state_current != SURF_RESOURCE_ON); action->suspended = 0; /* Should be useless because of the calloc but it seems to help valgrind... */ @@ -271,7 +279,7 @@ static surf_action_t action_sleep(void *cpu, double duration) if (duration > 0) duration = MAX(duration, MAXMIN_PRECISION); - XBT_IN2("(%s,%g)", ((cpu_Cas01_t) cpu)->generic_resource.name, duration); + XBT_IN2("(%s,%g)", surf_resource_name(cpu), duration); action = (surf_action_cpu_Cas01_t) execute(cpu, 1.0); action->generic_action.max_duration = duration; action->suspended = 2; @@ -336,6 +344,13 @@ static void action_set_priority(surf_action_t action, double priority) XBT_OUT; } +static double action_get_remains(surf_action_t action) +{ + XBT_IN1("(%p)", action); + return action->remains; + XBT_OUT; +} + static e_surf_resource_state_t get_state(void *cpu) { return ((cpu_Cas01_t) cpu)->state_current; @@ -391,6 +406,8 @@ static void surf_cpu_model_init_internal(void) surf_cpu_model->is_suspended = action_is_suspended; surf_cpu_model->set_max_duration = action_set_max_duration; surf_cpu_model->set_priority = action_set_priority; + surf_cpu_model->get_remains = action_get_remains; + surf_cpu_model->extension.cpu.execute = execute; surf_cpu_model->extension.cpu.sleep = action_sleep;