Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
give the application a chance to not enter the deadlocks
[simgrid.git] / src / simix / smx_global.cpp
index b1e0b70..9d33439 100644 (file)
@@ -165,6 +165,8 @@ static std::function<void()> maestro_code;
 namespace simgrid {
 namespace simix {
 
+simgrid::xbt::signal<void(void)> onDeadlock;
+
 XBT_PUBLIC(void) set_maestro(std::function<void()> code)
 {
   maestro_code = std::move(code);
@@ -531,9 +533,9 @@ void SIMIX_run()
     } while (again);
 
     /* Autorestart all process */
-    for (auto hostname: host_that_restart) {
-      XBT_INFO("Restart processes on host: %s", hostname.c_str());
-      SIMIX_host_autorestart(sg_host_by_name(hostname.c_str()));
+    for (auto host: host_that_restart) {
+      XBT_INFO("Restart processes on host: %s", sg_host_get_name(host));
+      SIMIX_host_autorestart(host);
     }
     host_that_restart.clear();
 
@@ -542,11 +544,15 @@ void SIMIX_run()
 
     XBT_DEBUG("### time %f, empty %d", time, xbt_dynar_is_empty(simix_global->process_to_run));
 
+    if (xbt_dynar_is_empty(simix_global->process_to_run) &&
+        xbt_swag_size(simix_global->process_list) != 0)
+    simgrid::simix::onDeadlock();
+
   } while (time > -1.0 || !xbt_dynar_is_empty(simix_global->process_to_run));
 
   if (xbt_swag_size(simix_global->process_list) != 0) {
 
-  TRACE_end();
+    TRACE_end();
 
     XBT_CRITICAL("Oops ! Deadlock or code not perfectly clean.");
     SIMIX_display_process_status();