From: navarro Date: Thu, 28 Jun 2012 12:28:40 +0000 (+0200) Subject: Add the function autorestart in simix_global X-Git-Tag: v3_8~424 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b4852fd3bb330d081de77ad7092fb2f11ee0b7a4 Add the function autorestart in simix_global --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index d61c83375c..960f5bdbd5 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -110,6 +110,8 @@ typedef struct s_smx_context_factory *smx_context_factory_t; /* Process creation/destruction callbacks */ typedef void (*void_pfn_smxprocess_t) (smx_process_t); +/* for function autorestart */ +typedef void (*void_pfn_smxhost_t) (smx_host_t); /* The following function pointer types describe the interface that any context factory should implement */ diff --git a/src/simix/smx_global.c b/src/simix/smx_global.c index abde774b8f..bc03b95d7d 100644 --- a/src/simix/smx_global.c +++ b/src/simix/smx_global.c @@ -78,6 +78,7 @@ void SIMIX_global_init(int *argc, char **argv) simix_global->action_mallocator = xbt_mallocator_new(65536, SIMIX_action_mallocator_new_f, SIMIX_action_mallocator_free_f, SIMIX_action_mallocator_reset_f); + simix_global->autorestart = SIMIX_host_restart_processes; surf_init(argc, argv); /* Initialize SURF structures */ SIMIX_context_mod_init(); diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index cc4273b864..1d41473a37 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -13,8 +13,6 @@ 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); /** @@ -275,6 +273,14 @@ void SIMIX_host_restart_processes(smx_host_t host) xbt_dynar_reset(host->auto_restart_processes); } +void SIMIX_host_autorestart(smx_host_t host) +{ + if(simix_global->autorestart) + simix_global->autorestart(host); + else + xbt_die("No function for simix_global->autorestart"); +} + void SIMIX_host_set_data(smx_host_t host, void *data) { xbt_assert((host != NULL), "Invalid parameters"); diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index 0b3244872c..59b9b977db 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -34,6 +34,7 @@ void SIMIX_host_add_auto_restart_process(smx_host_t host, xbt_dict_t properties, int auto_restart); void SIMIX_host_restart_processes(smx_host_t host); +void SIMIX_host_autorestart(smx_host_t host); xbt_dict_t SIMIX_host_get_properties(smx_host_t host); double SIMIX_host_get_speed(smx_host_t host); double SIMIX_host_get_available_speed(smx_host_t host); diff --git a/src/simix/smx_private.h b/src/simix/smx_private.h index 4d25f014d5..5bd6499f18 100644 --- a/src/simix/smx_private.h +++ b/src/simix/smx_private.h @@ -40,11 +40,14 @@ typedef struct s_smx_global { void_pfn_smxprocess_t kill_process_function; void_pfn_smxprocess_t cleanup_process_function; xbt_mallocator_t action_mallocator; + void_pfn_smxhost_t autorestart; } s_smx_global_t, *smx_global_t; extern smx_global_t simix_global; extern unsigned long simix_process_maxpid; +extern xbt_dict_t watched_hosts_lib; + /******************************** Exceptions *********************************/ #define SMX_EXCEPTION(issuer, c, v, m) \ diff --git a/src/surf/surf.c b/src/surf/surf.c index d2d0f2e6a4..515c6c4778 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -709,11 +709,9 @@ void surf_watched_hosts(void) 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); + XBT_INFO("Restart processes on host: %s",SIMIX_host_get_name(host)); + SIMIX_host_autorestart(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 6e87529dd2..3f24d74fd1 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -30,7 +30,7 @@ extern double sg_gtnets_jitter; extern int sg_gtnets_jitter_seed; #endif -extern xbt_dict_t watched_hosts_lib; +xbt_dict_t watched_hosts_lib; extern const char *surf_action_state_names[6];