X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/08e7455d67920bbd7a87f440d00f2c1e071314a0..d78a7f87e28a15c0f1e71e4510a055554e0e5e9b:/src/s4u/s4u_Mutex.cpp diff --git a/src/s4u/s4u_Mutex.cpp b/src/s4u/s4u_Mutex.cpp index 2bec1c841d..8975cb7bae 100644 --- a/src/s4u/s4u_Mutex.cpp +++ b/src/s4u/s4u_Mutex.cpp @@ -7,6 +7,7 @@ #include "simgrid/mutex.h" #include "simgrid/s4u/Mutex.hpp" #include "src/kernel/activity/MutexImpl.hpp" +#include "src/mc/checker/SimcallObserver.hpp" namespace simgrid { namespace s4u { @@ -20,7 +21,9 @@ Mutex::~Mutex() /** @brief Blocks the calling actor until the mutex can be obtained */ void Mutex::lock() { - simcall_mutex_lock(pimpl_); + kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self(); + mc::MutexLockSimcall observer{issuer, pimpl_}; + kernel::actor::simcall_blocking([&observer] { observer.get_mutex()->lock(observer.get_issuer()); }, &observer); } /** @brief Release the ownership of the mutex, unleashing a blocked actor (if any) @@ -29,13 +32,18 @@ void Mutex::lock() */ void Mutex::unlock() { - simcall_mutex_unlock(pimpl_); + kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self(); + mc::MutexUnlockSimcall observer{issuer}; + kernel::actor::simcall([this, issuer] { this->pimpl_->unlock(issuer); }, &observer); } /** @brief Acquire the mutex if it's free, and return false (without blocking) if not */ bool Mutex::try_lock() { - return simcall_mutex_trylock(pimpl_); + kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self(); + mc::MutexTrylockSimcall observer{issuer, pimpl_}; + return kernel::actor::simcall([&observer] { return observer.get_mutex()->try_lock(observer.get_issuer()); }, + &observer); } /** @brief Create a new mutex @@ -44,7 +52,7 @@ bool Mutex::try_lock() */ MutexPtr Mutex::create() { - kernel::activity::MutexImpl* mutex = kernel::actor::simcall([] { return new kernel::activity::MutexImpl(); }); + auto* mutex = new kernel::activity::MutexImpl(); return MutexPtr(&mutex->mutex(), false); }