]> AND Public Git Repository - simgrid.git/blobdiff - src/kernel/actor/SynchroObserver.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
And now cleanup the App-side of cruft that was needed for Checker to read actor infor...
[simgrid.git] / src / kernel / actor / SynchroObserver.cpp
index a0bc2c406db9bfec08c6f883d6a2704cfe77ef1a..5e5ca9d6b611794a70ec0aade3cdecf6cb3cd49b 100644 (file)
@@ -5,7 +5,9 @@
 
 #include "src/kernel/actor/SynchroObserver.hpp"
 #include "simgrid/s4u/Host.hpp"
+#include "src/kernel/activity/BarrierImpl.hpp"
 #include "src/kernel/activity/MutexImpl.hpp"
+#include "src/kernel/activity/SemaphoreImpl.hpp"
 #include "src/kernel/actor/ActorImpl.hpp"
 #include "src/mc/mc_config.hpp"
 
@@ -13,9 +15,7 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(obs_mutex, mc_observer, "Logging specific to mutex simcalls observation");
 
-namespace simgrid {
-namespace kernel {
-namespace actor {
+namespace simgrid::kernel::actor {
 
 MutexObserver::MutexObserver(ActorImpl* actor, mc::Transition::Type type, activity::MutexImpl* mutex)
     : SimcallObserver(actor), type_(type), mutex_(mutex)
@@ -35,6 +35,51 @@ bool MutexObserver::is_enabled()
   return type_ != mc::Transition::Type::MUTEX_WAIT || mutex_->get_owner() == get_issuer();
 }
 
-} // namespace actor
-} // namespace kernel
-} // namespace simgrid
+SemaphoreObserver::SemaphoreObserver(ActorImpl* actor, mc::Transition::Type type, activity::SemaphoreImpl* sem)
+    : SimcallObserver(actor), type_(type), sem_(sem)
+{
+  xbt_assert(sem_);
+}
+
+void SemaphoreObserver::serialize(std::stringstream& stream) const
+{
+  stream << (short)type_ << ' ' << get_sem()->get_id() << ' ' << false /* Granted is ignored for LOCK/UNLOCK */;
+}
+
+SemaphoreAcquisitionObserver::SemaphoreAcquisitionObserver(ActorImpl* actor, mc::Transition::Type type,
+                                                           activity::SemAcquisitionImpl* acqui, double timeout)
+    : ResultingSimcall(actor, false), type_(type), acquisition_(acqui), timeout_(timeout)
+{
+}
+bool SemaphoreAcquisitionObserver::is_enabled()
+{
+  return acquisition_->granted_;
+}
+void SemaphoreAcquisitionObserver::serialize(std::stringstream& stream) const
+{
+  stream << (short)type_ << ' ' << acquisition_->semaphore_->get_id() << ' ' << acquisition_->granted_;
+}
+
+BarrierObserver::BarrierObserver(ActorImpl* actor, mc::Transition::Type type, activity::BarrierImpl* bar)
+    : ResultingSimcall(actor, false), type_(type), barrier_(bar), timeout_(-1)
+{
+  xbt_assert(type_ == mc::Transition::Type::BARRIER_LOCK);
+}
+BarrierObserver::BarrierObserver(ActorImpl* actor, mc::Transition::Type type, activity::BarrierAcquisitionImpl* acqui,
+                                 double timeout)
+    : ResultingSimcall(actor, false), type_(type), acquisition_(acqui), timeout_(timeout)
+{
+  xbt_assert(type_ == mc::Transition::Type::BARRIER_WAIT);
+}
+void BarrierObserver::serialize(std::stringstream& stream) const
+{
+  xbt_assert(barrier_ != nullptr || (acquisition_ != nullptr && acquisition_->barrier_ != nullptr));
+  stream << (short)type_ << ' ' << (barrier_ != nullptr ? barrier_->get_id() : acquisition_->barrier_->get_id());
+}
+bool BarrierObserver::is_enabled()
+{
+  return type_ == mc::Transition::Type::BARRIER_LOCK ||
+         (type_ == mc::Transition::Type::BARRIER_WAIT && acquisition_ != nullptr && acquisition_->granted_);
+}
+
+} // namespace simgrid::kernel::actor