From 7341151507abf1d7931e8ca2df777541b5f6bfe2 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 26 Aug 2016 18:38:01 +0200 Subject: [PATCH] give the application a chance to not enter the deadlocks --- include/simgrid/simix.hpp | 6 ++++++ src/simix/smx_global.cpp | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/simgrid/simix.hpp b/include/simgrid/simix.hpp index fe3d4fd611..9b48240802 100644 --- a/include/simgrid/simix.hpp +++ b/include/simgrid/simix.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -86,6 +87,11 @@ typedef std::function 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 onDeadlock; } } diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index e78012d79a..9d33439151 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -165,6 +165,8 @@ static std::function maestro_code; namespace simgrid { namespace simix { +simgrid::xbt::signal onDeadlock; + XBT_PUBLIC(void) set_maestro(std::function 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(); -- 2.20.1