From e683f4e829813790c25870ccf9d43a18b8296d2a Mon Sep 17 00:00:00 2001 From: navarro Date: Thu, 28 Jun 2012 13:05:37 +0200 Subject: [PATCH] Create a dict with all hosts with state SURF_RESOURCE_OFF during a SIMIX_process_stop. --- src/include/surf/surf.h | 2 ++ src/simix/smx_host.c | 6 ++++++ src/surf/cpu_cas01.c | 2 ++ src/surf/cpu_ti.c | 2 ++ src/surf/surf.c | 24 ++++++++++++++++++++++++ src/surf/surf_private.h | 1 + 6 files changed, 37 insertions(+) diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 82536d7d06..7842c9e890 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -732,5 +732,7 @@ XBT_PUBLIC(double) get_cpu_power(const char *power); int surf_get_nthreads(void); void surf_set_nthreads(int nthreads); +void surf_watched_hosts(void); + SG_END_DECL() #endif /* _SURF_SURF_H */ diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index f663ea260a..b771e858ca 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -13,6 +13,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_host, simix, "Logging specific to SIMIX (hosts)"); +xbt_dict_t watched_hosts_lib; static void SIMIX_execution_finish(smx_action_t action); @@ -217,6 +218,11 @@ void SIMIX_host_add_auto_restart_process(smx_host_t host, arg->properties = properties; arg->auto_restart = auto_restart; + if( SIMIX_host_get_state(host) == SURF_RESOURCE_OFF + && !xbt_dict_get_or_null(watched_hosts_lib,host->name)){ + xbt_dict_set(watched_hosts_lib,host->name,host,NULL); + XBT_DEBUG("Have push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",host->name); + } xbt_dynar_push_as(host->auto_restart_processes,smx_process_arg_t,arg); } diff --git a/src/surf/cpu_cas01.c b/src/surf/cpu_cas01.c index 7025ee52b7..b427a5c839 100644 --- a/src/surf/cpu_cas01.c +++ b/src/surf/cpu_cas01.c @@ -173,6 +173,8 @@ static void cpu_update_resource_state(void *id, lmm_variable_t var = NULL; lmm_element_t elem = NULL; + surf_watched_hosts(); + if (event_type == cpu->power_event) { cpu->power_scale = value; lmm_update_constraint_bound(surf_cpu_model->model_private->maxmin_system, cpu->constraint, diff --git a/src/surf/cpu_ti.c b/src/surf/cpu_ti.c index 29cbf54b5f..a4e40b94dc 100644 --- a/src/surf/cpu_ti.c +++ b/src/surf/cpu_ti.c @@ -494,6 +494,8 @@ static void cpu_ti_update_resource_state(void *id, cpu_ti_t cpu = id; surf_action_cpu_ti_t action; + surf_watched_hosts(); + if (event_type == cpu->power_event) { tmgr_trace_t power_trace; surf_cpu_ti_tgmr_t trace; diff --git a/src/surf/surf.c b/src/surf/surf.c index 203febace3..d2d0f2e6a4 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -382,6 +382,7 @@ void surf_init(int *argc, char **argv) as_router_lib = xbt_lib_new(); storage_lib = xbt_lib_new(); storage_type_lib = xbt_lib_new(); + watched_hosts_lib = xbt_dict_new(); XBT_DEBUG("Add routing levels"); ROUTING_HOST_LEVEL = xbt_lib_add_level(host_lib,routing_asr_host_free); @@ -470,6 +471,8 @@ void surf_exit(void) xbt_lib_free(&storage_lib); xbt_lib_free(&storage_type_lib); + xbt_dict_free(&watched_hosts_lib); + tmgr_finalize(); surf_parse_lex_destroy(); surf_parse_free_callbacks(); @@ -695,3 +698,24 @@ void surf_set_nthreads(int nthreads) { surf_nthreads = nthreads; } + +void surf_watched_hosts(void) +{ + char *key; + void *host; + xbt_dict_cursor_t cursor; + + XBT_DEBUG("Check for host SURF_RESOURCE_ON on watched_hosts_lib"); + xbt_dict_foreach(watched_hosts_lib,cursor,key,host) + { + if(SIMIX_host_get_state(host) == SURF_RESOURCE_ON){ + XBT_DEBUG("See SURF_RESOURCE_ON on host: %s",SIMIX_host_get_name(host)); + // TODO need to restart all processes on host->auto_restart_processes + XBT_INFO("Should call SIMIX restart host here for '%s'",SIMIX_host_get_name(host)); + // TODO be sure having remove the wake up host + //xbt_dict_remove(watched_hosts_lib,key); + } + else + XBT_DEBUG("See SURF_RESOURCE_OFF on host: %s",key); + } +} diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 0736b551c0..6e87529dd2 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -30,6 +30,7 @@ extern double sg_gtnets_jitter; extern int sg_gtnets_jitter_seed; #endif +extern xbt_dict_t watched_hosts_lib; extern const char *surf_action_state_names[6]; -- 2.20.1