Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Create a dict with all hosts with state SURF_RESOURCE_OFF during a SIMIX_process_stop.
authornavarro <navarro@caraja.(none)>
Thu, 28 Jun 2012 11:05:37 +0000 (13:05 +0200)
committernavarro <navarro@caraja.(none)>
Thu, 28 Jun 2012 11:05:59 +0000 (13:05 +0200)
src/include/surf/surf.h
src/simix/smx_host.c
src/surf/cpu_cas01.c
src/surf/cpu_ti.c
src/surf/surf.c
src/surf/surf_private.h

index 82536d7..7842c9e 100644 (file)
@@ -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 */
index f663ea2..b771e85 100644 (file)
@@ -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);
 }
 
index 7025ee5..b427a5c 100644 (file)
@@ -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,
index 29cbf54..a4e40b9 100644 (file)
@@ -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;
index 203feba..d2d0f2e 100644 (file)
@@ -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);
+  }
+}
index 0736b55..6e87529 100644 (file)
@@ -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];