Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
give the application a chance to not enter the deadlocks
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 26 Aug 2016 16:38:01 +0000 (18:38 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 26 Aug 2016 16:38:01 +0000 (18:38 +0200)
include/simgrid/simix.hpp
src/simix/smx_global.cpp

index fe3d4fd..9b48240 100644 (file)
@@ -17,6 +17,7 @@
 #include <xbt/function_types.h>
 #include <xbt/future.hpp>
 #include <xbt/functional.hpp>
+#include <xbt/signal.hpp>
 
 #include <simgrid/simix.h>
 
@@ -86,6 +87,11 @@ typedef std::function<ActorCode(std::vector<std::string> args)> ActorCodeFactory
 
 XBT_PUBLIC(void) registerFunction(const char* name, ActorCodeFactory factory);
 
+/** These functions will be called when we detect a deadlock: any remaining process is locked on an action
+ *
+ * If these functions manage to unlock some of the processes, then the deadlock will be avoided.
+ */
+extern simgrid::xbt::signal<void(void)> onDeadlock;
 }
 }
 
index e78012d..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);
@@ -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();