X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d9c1e4df4ecfc39d84e55527fa05e9bd19f70c6c..0f0aacb167ddc9427ea1da1c8f1b66ef2d6f532e:/src/mc/explo/odpor/ReversibleRaceCalculator.cpp diff --git a/src/mc/explo/odpor/ReversibleRaceCalculator.cpp b/src/mc/explo/odpor/ReversibleRaceCalculator.cpp index 947ccc0903..a7de9b92ec 100644 --- a/src/mc/explo/odpor/ReversibleRaceCalculator.cpp +++ b/src/mc/explo/odpor/ReversibleRaceCalculator.cpp @@ -5,14 +5,26 @@ #include "src/mc/explo/odpor/ReversibleRaceCalculator.hpp" #include "src/mc/explo/odpor/Execution.hpp" +#include "src/mc/transition/Transition.hpp" +#include "src/mc/transition/TransitionSynchro.hpp" #include #include #include #include +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_odpor_reversible_race, mc_dfs, "ODPOR exploration algorithm of the model-checker"); + namespace simgrid::mc::odpor { +/** + The reversible race detector should only be used if we already have the assumption + e1 <* e2 (see Source set: a foundation for ODPOR). In particular this means that : + - e1 -->_E e2 + - proc(e1) != proc(e2) + - there is no event e3 s.t. e1 --> e3 --> e2 +*/ + bool ReversibleRaceCalculator::is_race_reversible(const Execution& E, Execution::EventHandle e1, Execution::EventHandle e2) { @@ -141,9 +153,9 @@ bool ReversibleRaceCalculator::is_race_reversible_MutexUnlock(const Execution&, bool ReversibleRaceCalculator::is_race_reversible_MutexWait(const Execution& E, Execution::EventHandle e1, const Transition* /*e2*/) { - // TODO: Get the semantics correct here - const auto e1_action = E.get_transition_for_handle(e1)->type_; - return e1_action != Transition::Type::MUTEX_ASYNC_LOCK && e1_action != Transition::Type::MUTEX_UNLOCK; + // TODO: for now we over approximate the reversibility + + return true; } bool ReversibleRaceCalculator::is_race_reversible_SemAsyncLock(const Execution&, Execution::EventHandle /*e1*/, @@ -160,11 +172,17 @@ bool ReversibleRaceCalculator::is_race_reversible_SemUnlock(const Execution&, Ex return true; } -bool ReversibleRaceCalculator::is_race_reversible_SemWait(const Execution&, Execution::EventHandle /*e1*/, +bool ReversibleRaceCalculator::is_race_reversible_SemWait(const Execution& E, Execution::EventHandle e1, const Transition* /*e2*/) { - // TODO: Get the semantics correct here - return false; + + const auto e1_transition = E.get_transition_for_handle(e1); + if (e1_transition->type_ == Transition::Type::SEM_UNLOCK && + static_cast(e1_transition)->get_capacity() <= 1) { + return false; + } + xbt_assert(false, "SEM_WAIT that is dependent with a SEM_UNLOCK should not be reversible. FixMe"); + return true; } bool ReversibleRaceCalculator::is_race_reversible_ObjectAccess(const Execution&, Execution::EventHandle /*e1*/, @@ -193,7 +211,7 @@ bool ReversibleRaceCalculator::is_race_reversible_WaitAny(const Execution&, Exec { // TODO: We need to check if any of the transitions // waited on occurred before `e1` - return false; + return true; // Let's overapproximate to not miss branches } } // namespace simgrid::mc::odpor