Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add the function autorestart in simix_global
authornavarro <navarro@caraja.(none)>
Thu, 28 Jun 2012 12:28:40 +0000 (14:28 +0200)
committernavarro <navarro@caraja.(none)>
Thu, 28 Jun 2012 12:28:40 +0000 (14:28 +0200)
include/simgrid/simix.h
src/simix/smx_global.c
src/simix/smx_host.c
src/simix/smx_host_private.h
src/simix/smx_private.h
src/surf/surf.c
src/surf/surf_private.h

index d61c833..960f5bd 100644 (file)
@@ -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 */
index abde774..bc03b95 100644 (file)
@@ -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();
index cc4273b..1d41473 100644 (file)
@@ -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");
index 0b32448..59b9b97 100644 (file)
@@ -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);
index 4d25f01..5bd6499 100644 (file)
@@ -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)                                  \
index d2d0f2e..515c6c4 100644 (file)
@@ -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);
index 6e87529..3f24d74 100644 (file)
@@ -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];