X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a8a66c743439c94d5de5bcb8a3e50dcd207b6d2f..1067edf07adcaa046abb976e7d92174d608b2d91:/src/kernel/actor/SynchroObserver.cpp diff --git a/src/kernel/actor/SynchroObserver.cpp b/src/kernel/actor/SynchroObserver.cpp index 8114a5eda2..50a4ce39eb 100644 --- a/src/kernel/actor/SynchroObserver.cpp +++ b/src/kernel/actor/SynchroObserver.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2019-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2019-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -30,8 +30,9 @@ void MutexObserver::serialize(std::stringstream& stream) const } std::string MutexObserver::to_string() const { - return std::string(mc::Transition::to_c_str(type_)) + "(mutex_id: " + std::to_string(get_mutex()->get_id()) + - "owner:" + std::to_string(get_mutex()->get_owner()->get_pid()) + ")"; + return std::string(mc::Transition::to_c_str(type_)) + "(mutex_id:" + std::to_string(get_mutex()->get_id()) + + " owner:" + + (get_mutex()->get_owner() == nullptr ? "none" : std::to_string(get_mutex()->get_owner()->get_pid())) + ")"; } bool MutexObserver::is_enabled() @@ -48,11 +49,12 @@ SemaphoreObserver::SemaphoreObserver(ActorImpl* actor, mc::Transition::Type type void SemaphoreObserver::serialize(std::stringstream& stream) const { - stream << (short)type_ << ' ' << get_sem()->get_id() << ' ' << false /* Granted is ignored for LOCK/UNLOCK */; + stream << (short)type_ << ' ' << get_sem()->get_id() << ' ' << false /* Granted is ignored for LOCK/UNLOCK */ << ' ' + << get_sem()->get_capacity(); } std::string SemaphoreObserver::to_string() const { - return std::string(mc::Transition::to_c_str(type_)) + "(sem_id: " + std::to_string(get_sem()->get_id()) + ")"; + return std::string(mc::Transition::to_c_str(type_)) + "(sem_id:" + std::to_string(get_sem()->get_id()) + ")"; } SemaphoreAcquisitionObserver::SemaphoreAcquisitionObserver(ActorImpl* actor, mc::Transition::Type type, @@ -66,12 +68,13 @@ bool SemaphoreAcquisitionObserver::is_enabled() } void SemaphoreAcquisitionObserver::serialize(std::stringstream& stream) const { - stream << (short)type_ << ' ' << acquisition_->semaphore_->get_id() << ' ' << acquisition_->granted_; + stream << (short)type_ << ' ' << acquisition_->semaphore_->get_id() << ' ' << acquisition_->granted_ << ' ' + << acquisition_->semaphore_->get_capacity(); } std::string SemaphoreAcquisitionObserver::to_string() const { return std::string(mc::Transition::to_c_str(type_)) + - "(sem_id: " + std::to_string(acquisition_->semaphore_->get_id()) + ' ' + + "(sem_id:" + std::to_string(acquisition_->semaphore_->get_id()) + ' ' + (acquisition_->granted_ ? "granted)" : "not granted)"); } @@ -94,7 +97,7 @@ void BarrierObserver::serialize(std::stringstream& stream) const std::string BarrierObserver::to_string() const { return std::string(mc::Transition::to_c_str(type_)) + - "(barrier_id: " + std::to_string(barrier_ != nullptr ? barrier_->get_id() : acquisition_->barrier_->get_id()) + + "(barrier_id:" + std::to_string(barrier_ != nullptr ? barrier_->get_id() : acquisition_->barrier_->get_id()) + ")"; } bool BarrierObserver::is_enabled() @@ -103,4 +106,22 @@ bool BarrierObserver::is_enabled() (type_ == mc::Transition::Type::BARRIER_WAIT && acquisition_ != nullptr && acquisition_->granted_); } +bool ConditionVariableObserver::is_enabled() +{ + if (static bool warned = false; not warned) { + XBT_INFO("Using condition variables in model-checked code is still experimental. Use at your own risk"); + warned = true; + } + return true; +} +void ConditionVariableObserver::serialize(std::stringstream& stream) const +{ + THROW_UNIMPLEMENTED; +} +std::string ConditionVariableObserver::to_string() const +{ + return "ConditionWait(cond_id:" + ptr_to_id(get_cond()) + + " mutex_id:" + std::to_string(get_mutex()->get_id()) + ")"; +} + } // namespace simgrid::kernel::actor