From: alegrand Date: Fri, 23 Mar 2007 11:21:38 +0000 (+0000) Subject: sleep actions can neither be suspended nor resumed... X-Git-Tag: v3.3~2020 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/45fee8d511c94661b7155ef561c4a5381592b9fb sleep actions can neither be suspended nor resumed... git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3340 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/surf/cpu.c b/src/surf/cpu.c index 240ee5352c..e5870e135c 100644 --- a/src/surf/cpu.c +++ b/src/surf/cpu.c @@ -236,6 +236,8 @@ static surf_action_t execute(void *cpu, double size) 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 = @@ -260,6 +262,7 @@ static surf_action_t action_sleep(void *cpu, double duration) 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; lmm_update_variable_weight(maxmin_system, action->variable, 0.0); XBT_OUT; return (surf_action_t) action; @@ -268,23 +271,29 @@ static surf_action_t action_sleep(void *cpu, double duration) 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(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(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) diff --git a/src/surf/cpu_private.h b/src/surf/cpu_private.h index 3e6d427629..7f93e3029b 100644 --- a/src/surf/cpu_private.h +++ b/src/surf/cpu_private.h @@ -14,6 +14,7 @@ typedef struct surf_action_cpu_Cas01 { s_surf_action_t generic_action; lmm_variable_t variable; + int suspended; } s_surf_action_cpu_Cas01_t, *surf_action_cpu_Cas01_t; typedef struct cpu_Cas01 { diff --git a/src/surf/network.c b/src/surf/network.c index 604aeb19c7..76411fb9a9 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -487,10 +487,12 @@ static void action_suspend(surf_action_t action) static void action_resume(surf_action_t action) { - lmm_update_variable_weight(maxmin_system, - ((surf_action_network_CM02_t) action)->variable, - ((surf_action_network_CM02_t) action)->lat_current); - ((surf_action_network_CM02_t) action)->suspended = 0; + if(((surf_action_network_CM02_t) action)->suspended) { + lmm_update_variable_weight(maxmin_system, + ((surf_action_network_CM02_t) action)->variable, + ((surf_action_network_CM02_t) action)->lat_current); + ((surf_action_network_CM02_t) action)->suspended = 0; + } } static int action_is_suspended(surf_action_t action) diff --git a/src/surf/workstation_KCCFLN05.c b/src/surf/workstation_KCCFLN05.c index 9b51404504..9d5c210e55 100644 --- a/src/surf/workstation_KCCFLN05.c +++ b/src/surf/workstation_KCCFLN05.c @@ -152,32 +152,36 @@ static void action_recycle(surf_action_t action) static void action_suspend(surf_action_t action) { XBT_IN1("(%p))",action); - ((surf_action_workstation_KCCFLN05_t) action)->suspended = 1; - lmm_update_variable_weight(maxmin_system, - ((surf_action_workstation_KCCFLN05_t) - action)->variable, 0.0); + if(((surf_action_workstation_KCCFLN05_t) action)->suspended != 2) { + ((surf_action_workstation_KCCFLN05_t) action)->suspended = 1; + lmm_update_variable_weight(maxmin_system, + ((surf_action_workstation_KCCFLN05_t) + action)->variable, 0.0); + } XBT_OUT; } static void action_resume(surf_action_t action) { XBT_IN1("(%p)",action); - if(((surf_action_workstation_KCCFLN05_t)action)->lat_current==0.0) - lmm_update_variable_weight(maxmin_system, - ((surf_action_workstation_KCCFLN05_t) - action)->variable, 1.0); - else - lmm_update_variable_weight(maxmin_system, - ((surf_action_workstation_KCCFLN05_t) action)->variable, - ((surf_action_workstation_KCCFLN05_t) action)->lat_current); - - ((surf_action_workstation_KCCFLN05_t) action)->suspended = 0; + if(((surf_action_workstation_KCCFLN05_t) action)->suspended !=2) { + if(((surf_action_workstation_KCCFLN05_t)action)->lat_current==0.0) + lmm_update_variable_weight(maxmin_system, + ((surf_action_workstation_KCCFLN05_t) + action)->variable, 1.0); + else + lmm_update_variable_weight(maxmin_system, + ((surf_action_workstation_KCCFLN05_t) action)->variable, + ((surf_action_workstation_KCCFLN05_t) action)->lat_current); + + ((surf_action_workstation_KCCFLN05_t) action)->suspended = 0; + } XBT_OUT; } static int action_is_suspended(surf_action_t action) { - return (((surf_action_workstation_KCCFLN05_t) action)->suspended); + return (((surf_action_workstation_KCCFLN05_t) action)->suspended==1); } static void action_set_max_duration(surf_action_t action, double duration) @@ -258,7 +262,7 @@ static void update_actions_state(double now, double delta) double_update(&(deltap), action->latency); action->latency = 0.0; } - if ((action->latency == 0.0) && !(action->suspended)) { + if ((action->latency == 0.0) && (action->suspended==0)) { if((action)->lat_current==0.0) lmm_update_variable_weight(maxmin_system,action->variable, 1.0); else @@ -339,7 +343,7 @@ static void update_resource_state(void *id, else lmm_update_variable_bound(maxmin_system, action->variable, min(action->rate,SG_TCP_CTE_GAMMA / (2.0 * action->lat_current))); - if(!(action->suspended)) + if(action->suspended==0) lmm_update_variable_weight(maxmin_system, action->variable, action->lat_current); } @@ -458,6 +462,7 @@ static surf_action_t action_sleep(void *cpu, double duration) action = (surf_action_workstation_KCCFLN05_t) execute(cpu, 1.0); action->generic_action.max_duration = duration; + action->suspended = 2; lmm_update_variable_weight(maxmin_system, action->variable, 0.0); XBT_OUT;