From: Frederic Suter Date: Wed, 13 Mar 2019 12:15:12 +0000 (+0100) Subject: comestics in src/kernel X-Git-Tag: v3_22~107 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/001737a15701027974d89260771284a45013d2cd comestics in src/kernel --- diff --git a/src/kernel/EngineImpl.cpp b/src/kernel/EngineImpl.cpp index ad9b5e1be6..77390cb070 100644 --- a/src/kernel/EngineImpl.cpp +++ b/src/kernel/EngineImpl.cpp @@ -15,15 +15,12 @@ namespace simgrid { namespace kernel { -EngineImpl::EngineImpl() = default; EngineImpl::~EngineImpl() { /* copy all names to not modify the map while iterating over it. * - * Plus, the hosts are destroyed in the lexicographic order to ensure - * that the output is reproducible: we don't want to kill them in the - * pointer order as it could be platform-dependent, which would break - * the tests. + * Plus, the hosts are destroyed in the lexicographic order to ensure that the output is reproducible: we don't want + * to kill them in the pointer order as it could be platform-dependent, which would break the tests. */ std::vector names; for (auto const& kv : hosts_) diff --git a/src/kernel/EngineImpl.hpp b/src/kernel/EngineImpl.hpp index 27530d9b10..0778432f71 100644 --- a/src/kernel/EngineImpl.hpp +++ b/src/kernel/EngineImpl.hpp @@ -13,19 +13,20 @@ namespace simgrid { namespace kernel { class EngineImpl { + std::map hosts_; + std::map links_; + std::map storages_; + std::unordered_map netpoints_; + friend s4u::Engine; + public: - EngineImpl(); + EngineImpl() = default; + ; EngineImpl(const EngineImpl&) = delete; EngineImpl& operator=(const EngineImpl&) = delete; virtual ~EngineImpl(); - kernel::routing::NetZoneImpl* netzone_root_ = nullptr; - -private: - std::map hosts_; - std::map links_; - std::map storages_; - std::unordered_map netpoints_; - friend simgrid::s4u::Engine; + routing::NetZoneImpl* netzone_root_ = nullptr; }; -} -} + +} // namespace kernel +} // namespace simgrid diff --git a/src/kernel/activity/ActivityImpl.hpp b/src/kernel/activity/ActivityImpl.hpp index 0bfa6025ed..ed5dc6c0ef 100644 --- a/src/kernel/activity/ActivityImpl.hpp +++ b/src/kernel/activity/ActivityImpl.hpp @@ -47,9 +47,11 @@ private: std::string name_; /* Activity name if any */ public: - static simgrid::xbt::signal on_suspended; - static simgrid::xbt::signal on_resumed; + static xbt::signal on_suspended; + static xbt::signal on_resumed; }; -}}} // namespace simgrid::kernel::activity +} // namespace activity +} // namespace kernel +} // namespace simgrid #endif /* SIMGRID_KERNEL_ACTIVITY_ACTIVITYIMPL_HPP */ diff --git a/src/kernel/activity/CommImpl.hpp b/src/kernel/activity/CommImpl.hpp index 22710cfb97..f881e04d38 100644 --- a/src/kernel/activity/CommImpl.hpp +++ b/src/kernel/activity/CommImpl.hpp @@ -32,22 +32,21 @@ public: void cancel(); double remains(); - CommImpl::Type type; /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */ - smx_mailbox_t mbox = nullptr; /* Rendez-vous where the comm is queued */ + CommImpl::Type type; /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */ + MailboxImpl* mbox = nullptr; /* Rendez-vous where the comm is queued */ #if SIMGRID_HAVE_MC - smx_mailbox_t mbox_cpy = nullptr; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR + MailboxImpl* mbox_cpy = nullptr; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR (comm.mbox set to nullptr when the communication is removed from the mailbox (used as garbage collector)) */ #endif bool detached = false; /* If detached or not */ void (*clean_fun)(void*) = nullptr; /* Function to clean the detached src_buf if something goes wrong */ - int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*) = - nullptr; /* Filter function used by the other side. It is used when + int (*match_fun)(void*, void*, CommImpl*) = nullptr; /* Filter function used by the other side. It is used when looking if a given communication matches my needs. For that, myself must match the expectations of the other side, too. See */ - void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t) = nullptr; + void (*copy_data_fun)(CommImpl*, void*, size_t) = nullptr; /* Surf action data */ resource::Action* surf_action_ = nullptr; /* The Surf communication action encapsulated */ @@ -68,8 +67,8 @@ expectations of the other side, too. See */ void* src_data_ = nullptr; /* User data associated to the communication */ void* dst_data_ = nullptr; }; -} -} -} // namespace simgrid::kernel::activity +} // namespace activity +} // namespace kernel +} // namespace simgrid #endif diff --git a/src/kernel/activity/ConditionVariableImpl.cpp b/src/kernel/activity/ConditionVariableImpl.cpp index f57aa355f5..a46a9042cc 100644 --- a/src/kernel/activity/ConditionVariableImpl.cpp +++ b/src/kernel/activity/ConditionVariableImpl.cpp @@ -60,7 +60,7 @@ void ConditionVariableImpl::signal() /* Now transform the cond wait simcall into a mutex lock one */ smx_simcall_t simcall = &proc.simcall; - smx_mutex_t simcall_mutex; + MutexImpl* simcall_mutex; if (simcall->call == SIMCALL_COND_WAIT) simcall_mutex = simcall_cond_wait__get__mutex(simcall); else @@ -87,7 +87,7 @@ void ConditionVariableImpl::broadcast() signal(); } -void ConditionVariableImpl::wait(smx_mutex_t mutex, double timeout, smx_actor_t issuer, smx_simcall_t simcall) +void ConditionVariableImpl::wait(smx_mutex_t mutex, double timeout, actor::ActorImpl* issuer, smx_simcall_t simcall) { XBT_IN("(%p, %p, %f, %p,%p)", this, mutex, timeout, issuer, simcall); RawImplPtr synchro = nullptr; diff --git a/src/kernel/activity/ConditionVariableImpl.hpp b/src/kernel/activity/ConditionVariableImpl.hpp index 6749e7821f..f165dde62f 100644 --- a/src/kernel/activity/ConditionVariableImpl.hpp +++ b/src/kernel/activity/ConditionVariableImpl.hpp @@ -19,13 +19,13 @@ public: ConditionVariableImpl(); ~ConditionVariableImpl(); - simgrid::kernel::actor::SynchroList sleeping_; /* list of sleeping processes */ - smx_mutex_t mutex_ = nullptr; - simgrid::s4u::ConditionVariable cond_; + actor::SynchroList sleeping_; /* list of sleeping processes */ + MutexImpl* mutex_ = nullptr; + s4u::ConditionVariable cond_; void broadcast(); void signal(); - void wait(smx_mutex_t mutex, double timeout, smx_actor_t issuer, smx_simcall_t simcall); + void wait(MutexImpl* mutex, double timeout, actor::ActorImpl* issuer, smx_simcall_t simcall); private: std::atomic_int_fast32_t refcount_{1}; diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index 452d6fd288..4b66dd21bb 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -224,7 +224,7 @@ void ExecImpl::finish() } } -ActivityImpl* ExecImpl::migrate(simgrid::s4u::Host* to) +ActivityImpl* ExecImpl::migrate(s4u::Host* to) { if (not MC_is_active() && not MC_record_replay_is_active()) { resource::Action* old_action = this->surf_action_; diff --git a/src/kernel/activity/ExecImpl.hpp b/src/kernel/activity/ExecImpl.hpp index 607e671d77..74daa44dd2 100644 --- a/src/kernel/activity/ExecImpl.hpp +++ b/src/kernel/activity/ExecImpl.hpp @@ -15,6 +15,7 @@ namespace kernel { namespace activity { class XBT_PUBLIC ExecImpl : public ActivityImpl { + resource::Action* timeout_detector_ = nullptr; ~ExecImpl() override; public: @@ -38,15 +39,11 @@ public: /* The host where the execution takes place. nullptr means this is a parallel exec (and only surf knows the hosts) */ s4u::Host* host_ = nullptr; -private: - resource::Action* timeout_detector_ = nullptr; - -public: - static simgrid::xbt::signal on_creation; - static simgrid::xbt::signal on_completion; - static simgrid::xbt::signal on_migration; + static xbt::signal on_creation; + static xbt::signal on_completion; + static xbt::signal on_migration; }; -} -} -} // namespace simgrid::kernel::activity +} // namespace activity +} // namespace kernel +} // namespace simgrid #endif diff --git a/src/kernel/activity/IoImpl.hpp b/src/kernel/activity/IoImpl.hpp index 653d191517..52d0aa793b 100644 --- a/src/kernel/activity/IoImpl.hpp +++ b/src/kernel/activity/IoImpl.hpp @@ -31,8 +31,8 @@ public: static xbt::signal on_start; static xbt::signal on_completion; }; -} -} -} // namespace simgrid::kernel::activity +} // namespace activity +} // namespace kernel +} // namespace simgrid #endif diff --git a/src/kernel/activity/MailboxImpl.cpp b/src/kernel/activity/MailboxImpl.cpp index ad182f233a..9ead4eca0b 100644 --- a/src/kernel/activity/MailboxImpl.cpp +++ b/src/kernel/activity/MailboxImpl.cpp @@ -40,7 +40,7 @@ MailboxImpl* MailboxImpl::by_name_or_create(const std::string& name) /* two processes may have pushed the same mbox_create simcall at the same time */ auto m = mailboxes->find(name); if (m == mailboxes->end()) { - smx_mailbox_t mbox = new MailboxImpl(name); + MailboxImpl* mbox = new MailboxImpl(name); XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name.c_str()); (*mailboxes)[mbox->name_] = mbox; return mbox; @@ -151,6 +151,6 @@ CommImplPtr MailboxImpl::find_matching_comm(CommImpl::Type type, int (*match_fun XBT_DEBUG("No matching communication synchro found"); return nullptr; } -} -} -} +} // namespace activity +} // namespace kernel +} // namespace simgrid diff --git a/src/kernel/activity/MailboxImpl.hpp b/src/kernel/activity/MailboxImpl.hpp index 0c8246bd5c..29b561c5c4 100644 --- a/src/kernel/activity/MailboxImpl.hpp +++ b/src/kernel/activity/MailboxImpl.hpp @@ -17,7 +17,7 @@ namespace simgrid { namespace kernel { namespace activity { -/** @brief Implementation of the simgrid::s4u::Mailbox */ +/** @brief Implementation of the s4u::Mailbox */ class MailboxImpl { static constexpr size_t MAX_MAILBOX_SIZE = 10000000; @@ -32,7 +32,7 @@ class MailboxImpl { } public: - const simgrid::xbt::string& get_name() const { return name_; } + const xbt::string& get_name() const { return name_; } const char* get_cname() const { return name_.c_str(); } static MailboxImpl* by_name_or_null(const std::string& name); static MailboxImpl* by_name_or_create(const std::string& name); @@ -44,18 +44,18 @@ public: const CommImplPtr& my_synchro, bool done, bool remove_matching); private: - simgrid::s4u::Mailbox piface_; - simgrid::xbt::string name_; + s4u::Mailbox piface_; + xbt::string name_; public: - simgrid::kernel::actor::ActorImplPtr permanent_receiver_; // actor to which the mailbox is attached + actor::ActorImplPtr permanent_receiver_; // actor to which the mailbox is attached boost::circular_buffer_space_optimized comm_queue_; boost::circular_buffer_space_optimized done_comm_queue_; // messages already received in the permanent // receive mode }; -} -} -} +} // namespace activity +} // namespace kernel +} // namespace simgrid XBT_PRIVATE void SIMIX_mailbox_exit(); diff --git a/src/kernel/activity/MutexImpl.cpp b/src/kernel/activity/MutexImpl.cpp index 624c80b3c3..883f135bbd 100644 --- a/src/kernel/activity/MutexImpl.cpp +++ b/src/kernel/activity/MutexImpl.cpp @@ -24,23 +24,23 @@ MutexImpl::~MutexImpl() XBT_OUT(); } -void MutexImpl::lock(smx_actor_t issuer) +void MutexImpl::lock(actor::ActorImpl* issuer) { XBT_IN("(%p; %p)", this, issuer); /* FIXME: check where to validate the arguments */ RawImplPtr synchro = nullptr; - if (this->locked) { + if (locked_) { /* FIXME: check if the host is active ? */ /* Somebody using the mutex, use a synchronization to get host failures */ synchro = RawImplPtr(new RawImpl())->start(issuer->get_host(), -1); synchro->simcalls_.push_back(&issuer->simcall); issuer->waiting_synchro = synchro; - this->sleeping.push_back(*issuer); + sleeping_.push_back(*issuer); } else { /* mutex free */ - this->locked = true; - this->owner = issuer; + locked_ = true; + owner_ = issuer; SIMIX_simcall_answer(&issuer->simcall); } XBT_OUT(); @@ -51,16 +51,16 @@ void MutexImpl::lock(smx_actor_t issuer) * @param issuer the process that tries to acquire the mutex * @return whether we managed to lock the mutex */ -bool MutexImpl::try_lock(smx_actor_t issuer) +bool MutexImpl::try_lock(actor::ActorImpl* issuer) { XBT_IN("(%p, %p)", this, issuer); - if (this->locked) { + if (locked_) { XBT_OUT(); return false; } - this->locked = true; - this->owner = issuer; + locked_ = true; + owner_ = issuer; XBT_OUT(); return true; } @@ -71,28 +71,28 @@ bool MutexImpl::try_lock(smx_actor_t issuer) * If the unlocker is not the owner of the mutex nothing happens. * If there are no process waiting, it sets the mutex as free. */ -void MutexImpl::unlock(smx_actor_t issuer) +void MutexImpl::unlock(actor::ActorImpl* issuer) { XBT_IN("(%p, %p)", this, issuer); - if (not this->locked) + if (not locked_) THROWF(mismatch_error, 0, "Cannot release that mutex: it was not locked."); /* If the mutex is not owned by the issuer, that's not good */ - if (issuer != this->owner) + if (issuer != owner_) THROWF(mismatch_error, 0, "Cannot release that mutex: it was locked by %s (pid:%ld), not by you.", - this->owner->get_cname(), this->owner->get_pid()); + owner_->get_cname(), owner_->get_pid()); - if (not this->sleeping.empty()) { + if (not sleeping_.empty()) { /*process to wake up */ - smx_actor_t p = &this->sleeping.front(); - this->sleeping.pop_front(); + actor::ActorImpl* p = &sleeping_.front(); + sleeping_.pop_front(); p->waiting_synchro = nullptr; - this->owner = p; + owner_ = p; SIMIX_simcall_answer(&p->simcall); } else { /* nobody to wake up */ - this->locked = false; - this->owner = nullptr; + locked_ = false; + owner_ = nullptr; } XBT_OUT(); } diff --git a/src/kernel/activity/MutexImpl.hpp b/src/kernel/activity/MutexImpl.hpp index 37846cbd1c..b60f735778 100644 --- a/src/kernel/activity/MutexImpl.hpp +++ b/src/kernel/activity/MutexImpl.hpp @@ -21,16 +21,16 @@ public: MutexImpl(MutexImpl const&) = delete; MutexImpl& operator=(MutexImpl const&) = delete; - void lock(smx_actor_t issuer); - bool try_lock(smx_actor_t issuer); - void unlock(smx_actor_t issuer); + void lock(actor::ActorImpl* issuer); + bool try_lock(actor::ActorImpl* issuer); + void unlock(actor::ActorImpl* issuer); MutexImpl* ref(); void unref(); - bool locked = false; - smx_actor_t owner = nullptr; - // List of sleeping processes: - simgrid::kernel::actor::SynchroList sleeping; + bool locked_ = false; + actor::ActorImpl* owner_ = nullptr; + // List of sleeping actors: + actor::SynchroList sleeping_; // boost::intrusive_ptr support: friend void intrusive_ptr_add_ref(MutexImpl* mutex) @@ -38,17 +38,18 @@ public: XBT_ATTRIB_UNUSED auto previous = mutex->refcount_.fetch_add(1); xbt_assert(previous != 0); } + friend void intrusive_ptr_release(MutexImpl* mutex) { if (mutex->refcount_.fetch_sub(1) == 1) delete mutex; } - simgrid::s4u::Mutex& mutex() { return piface_; } + s4u::Mutex& mutex() { return piface_; } private: std::atomic_int_fast32_t refcount_{1}; - simgrid::s4u::Mutex piface_; + s4u::Mutex piface_; }; } } diff --git a/src/kernel/activity/SemaphoreImpl.cpp b/src/kernel/activity/SemaphoreImpl.cpp index 86d1e9ef24..bf20f2b924 100644 --- a/src/kernel/activity/SemaphoreImpl.cpp +++ b/src/kernel/activity/SemaphoreImpl.cpp @@ -12,7 +12,7 @@ namespace simgrid { namespace kernel { namespace activity { -void SemaphoreImpl::acquire(smx_actor_t issuer, double timeout) +void SemaphoreImpl::acquire(actor::ActorImpl* issuer, double timeout) { RawImplPtr synchro = nullptr; diff --git a/src/kernel/activity/SemaphoreImpl.hpp b/src/kernel/activity/SemaphoreImpl.hpp index b528e0eb7e..73faa7baf5 100644 --- a/src/kernel/activity/SemaphoreImpl.hpp +++ b/src/kernel/activity/SemaphoreImpl.hpp @@ -24,7 +24,7 @@ public: SemaphoreImpl(SemaphoreImpl const&) = delete; SemaphoreImpl& operator=(SemaphoreImpl const&) = delete; - void acquire(smx_actor_t issuer, double timeout); + void acquire(actor::ActorImpl* issuer, double timeout); void release(); bool would_block() { return (value_ == 0); } unsigned int get_capacity() { return value_; } diff --git a/src/kernel/activity/SleepImpl.hpp b/src/kernel/activity/SleepImpl.hpp index 32e6820bb9..2bf4657a3b 100644 --- a/src/kernel/activity/SleepImpl.hpp +++ b/src/kernel/activity/SleepImpl.hpp @@ -24,8 +24,8 @@ public: sg_host_t host_ = nullptr; }; -} -} -} // namespace simgrid::kernel::activity +} // namespace activity +} // namespace kernel +} // namespace simgrid #endif diff --git a/src/kernel/activity/SynchroRaw.cpp b/src/kernel/activity/SynchroRaw.cpp index 8961561fc2..d58e1e4e18 100644 --- a/src/kernel/activity/SynchroRaw.cpp +++ b/src/kernel/activity/SynchroRaw.cpp @@ -80,7 +80,7 @@ void RawImpl::finish() switch (simcall->call) { case SIMCALL_MUTEX_LOCK: - simgrid::xbt::intrusive_erase(simcall_mutex_lock__get__mutex(simcall)->sleeping, *simcall->issuer); + simgrid::xbt::intrusive_erase(simcall_mutex_lock__get__mutex(simcall)->sleeping_, *simcall->issuer); break; case SIMCALL_COND_WAIT: diff --git a/src/kernel/activity/SynchroRaw.hpp b/src/kernel/activity/SynchroRaw.hpp index 91158611f0..da5766bfd8 100644 --- a/src/kernel/activity/SynchroRaw.hpp +++ b/src/kernel/activity/SynchroRaw.hpp @@ -23,6 +23,8 @@ public: void post() override; void finish() override; }; -}}} // namespace simgrid::kernel::activity +} // namespace activity +} // namespace kernel +} // namespace simgrid #endif diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 9e386fa15f..1c2fcfb5f4 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -145,7 +145,7 @@ void ActorImpl::cleanup() simgrid::xbt::intrusive_erase(host_->pimpl_->process_list_, *this); if (not smx_destroy_list_hook.is_linked()) { #if SIMGRID_HAVE_MC - xbt_dynar_push_as(simix_global->dead_actors_vector, smx_actor_t, this); + xbt_dynar_push_as(simix_global->dead_actors_vector, ActorImpl*, this); #endif simix_global->actors_to_destroy.push_back(*this); } @@ -367,15 +367,15 @@ void ActorImpl::resume() XBT_OUT(); } -activity::ActivityImplPtr ActorImpl::join(smx_actor_t actor, double timeout) +activity::ActivityImplPtr ActorImpl::join(ActorImpl* actor, double timeout) { activity::ActivityImplPtr res = this->sleep(timeout); intrusive_ptr_add_ref(res.get()); SIMIX_process_on_exit(actor, [](int, void* arg) { - auto sleep = static_cast(arg); + auto sleep = static_cast(arg); if (sleep->surf_action_) - sleep->surf_action_->finish(simgrid::kernel::resource::Action::State::FINISHED); + sleep->surf_action_->finish(resource::Action::State::FINISHED); intrusive_ptr_release(sleep); }, res.get()); @@ -388,8 +388,7 @@ activity::ActivityImplPtr ActorImpl::sleep(double duration) throw_exception(std::make_exception_ptr(simgrid::HostFailureException( XBT_THROW_POINT, std::string("Host ") + host_->get_cname() + " failed, you cannot sleep there."))); - return simgrid::kernel::activity::SleepImplPtr(new simgrid::kernel::activity::SleepImpl("sleep", host_)) - ->start(duration); + return activity::SleepImplPtr(new activity::SleepImpl("sleep", host_))->start(duration); } void ActorImpl::throw_exception(std::exception_ptr e) @@ -438,14 +437,14 @@ void ActorImpl::throw_exception(std::exception_ptr e) void ActorImpl::set_host(s4u::Host* dest) { - simgrid::xbt::intrusive_erase(host_->pimpl_->process_list_, *this); + xbt::intrusive_erase(host_->pimpl_->process_list_, *this); host_ = dest; dest->pimpl_->process_list_.push_back(*this); } ActorImplPtr ActorImpl::init(const std::string& name, s4u::Host* host) { - ActorImpl* actor = new ActorImpl(simgrid::xbt::string(name), host); + ActorImpl* actor = new ActorImpl(xbt::string(name), host); actor->set_ppid(this->pid_); intrusive_ptr_add_ref(actor); @@ -490,9 +489,9 @@ ActorImplPtr ActorImpl::create(const std::string& name, const simix::ActorCode& ActorImplPtr actor; if (parent_actor != nullptr) - actor = parent_actor->init(simgrid::xbt::string(name), host); + actor = parent_actor->init(xbt::string(name), host); else - actor = SIMIX_process_self()->init(simgrid::xbt::string(name), host); + actor = SIMIX_process_self()->init(xbt::string(name), host); /* actor data */ actor->set_user_data(data); diff --git a/src/kernel/context/Context.cpp b/src/kernel/context/Context.cpp index 16517db16a..dc182b945f 100644 --- a/src/kernel/context/Context.cpp +++ b/src/kernel/context/Context.cpp @@ -41,19 +41,19 @@ void Context::declare_context(std::size_t size) #endif } -Context* ContextFactory::attach(smx_actor_t) +Context* ContextFactory::attach(actor::ActorImpl*) { xbt_die("Cannot attach with this ContextFactory.\n" "Try using --cfg=contexts/factory:thread instead.\n"); } -Context* ContextFactory::create_maestro(std::function&&, smx_actor_t) +Context* ContextFactory::create_maestro(std::function&&, actor::ActorImpl*) { xbt_die("Cannot create_maestro with this ContextFactory.\n" "Try using --cfg=contexts/factory:thread instead.\n"); } -Context::Context(std::function&& code, smx_actor_t actor) : code_(std::move(code)), actor_(actor) +Context::Context(std::function&& code, actor::ActorImpl* actor) : code_(std::move(code)), actor_(actor) { /* If no function was provided, this is the context for maestro * and we should set it as the current context */ @@ -112,7 +112,9 @@ void Context::stop() AttachContext::~AttachContext() = default; -}}} +} // namespace context +} // namespace kernel +} // namespace simgrid /** @brief Executes all the processes to run (in parallel if possible). */ void SIMIX_context_runall() diff --git a/src/kernel/context/Context.hpp b/src/kernel/context/Context.hpp index ae50c28a81..60504fafd0 100644 --- a/src/kernel/context/Context.hpp +++ b/src/kernel/context/Context.hpp @@ -22,12 +22,12 @@ public: ContextFactory(const ContextFactory&) = delete; ContextFactory& operator=(const ContextFactory&) = delete; virtual ~ContextFactory(); - virtual Context* create_context(std::function&& code, smx_actor_t actor) = 0; + virtual Context* create_context(std::function&& code, actor::ActorImpl* actor) = 0; /** Turn the current thread into a simulation context */ - virtual Context* attach(smx_actor_t actor); + virtual Context* attach(actor::ActorImpl* actor); /** Turn the current thread into maestro (the old maestro becomes a regular actor) */ - virtual Context* create_maestro(std::function&& code, smx_actor_t actor); + virtual Context* create_maestro(std::function&& code, actor::ActorImpl* actor); virtual void run_all() = 0; @@ -44,20 +44,20 @@ class XBT_PUBLIC Context { friend ContextFactory; std::function code_; - smx_actor_t actor_ = nullptr; + actor::ActorImpl* actor_ = nullptr; void declare_context(std::size_t size); public: bool iwannadie = false; - Context(std::function&& code, smx_actor_t actor); + Context(std::function&& code, actor::ActorImpl* actor); Context(const Context&) = delete; Context& operator=(const Context&) = delete; virtual ~Context(); void operator()() { code_(); } bool has_code() const { return static_cast(code_); } - smx_actor_t get_actor() { return this->actor_; } + actor::ActorImpl* get_actor() { return this->actor_; } // Scheduling methods virtual void stop(); @@ -72,7 +72,7 @@ public: class XBT_PUBLIC AttachContext : public Context { public: - AttachContext(std::function&& code, smx_actor_t actor) : Context(std::move(code), actor) {} + AttachContext(std::function&& code, actor::ActorImpl* actor) : Context(std::move(code), actor) {} AttachContext(const AttachContext&) = delete; AttachContext& operator=(const AttachContext&) = delete; ~AttachContext() override; @@ -96,7 +96,9 @@ XBT_PRIVATE ContextFactory* sysv_factory(); XBT_PRIVATE ContextFactory* raw_factory(); XBT_PRIVATE ContextFactory* boost_factory(); -}}} +} // namespace context +} // namespace kernel +} // namespace simgrid typedef simgrid::kernel::context::ContextFactory *smx_context_factory_t; diff --git a/src/kernel/context/ContextBoost.cpp b/src/kernel/context/ContextBoost.cpp index 9717474bc6..1ba7c36750 100644 --- a/src/kernel/context/ContextBoost.cpp +++ b/src/kernel/context/ContextBoost.cpp @@ -15,14 +15,14 @@ namespace kernel { namespace context { // BoostContextFactory -smx_context_t BoostContextFactory::create_context(std::function&& code, smx_actor_t actor) +smx_context_t BoostContextFactory::create_context(std::function&& code, actor::ActorImpl* actor) { return this->new_context(std::move(code), actor, this); } // BoostContext -BoostContext::BoostContext(std::function&& code, smx_actor_t actor, SwappedContextFactory* factory) +BoostContext::BoostContext(std::function&& code, actor::ActorImpl* actor, SwappedContextFactory* factory) : SwappedContext(std::move(code), actor, factory) { @@ -103,4 +103,6 @@ XBT_PRIVATE ContextFactory* boost_factory() XBT_VERB("Using Boost contexts. Welcome to the 21th century."); return new BoostContextFactory(); } -}}} // namespace +} // namespace context +} // namespace kernel +} // namespace simgrid diff --git a/src/kernel/context/ContextBoost.hpp b/src/kernel/context/ContextBoost.hpp index cac896cab9..082c6e80bf 100644 --- a/src/kernel/context/ContextBoost.hpp +++ b/src/kernel/context/ContextBoost.hpp @@ -32,7 +32,7 @@ namespace context { /** @brief Userspace context switching implementation based on Boost.Context */ class BoostContext : public SwappedContext { public: - BoostContext(std::function&& code, smx_actor_t actor, SwappedContextFactory* factory); + BoostContext(std::function&& code, actor::ActorImpl* actor, SwappedContextFactory* factory); ~BoostContext() override; void swap_into(SwappedContext* to) override; @@ -54,8 +54,10 @@ private: class BoostContextFactory : public SwappedContextFactory { public: - Context* create_context(std::function&& code, smx_actor_t actor) override; + Context* create_context(std::function&& code, actor::ActorImpl* actor) override; }; -}}} // namespace +} // namespace context +} // namespace kernel +} // namespace simgrid #endif diff --git a/src/kernel/context/ContextRaw.cpp b/src/kernel/context/ContextRaw.cpp index 328e8f595b..11a7888734 100644 --- a/src/kernel/context/ContextRaw.cpp +++ b/src/kernel/context/ContextRaw.cpp @@ -188,14 +188,14 @@ namespace context { // RawContextFactory -Context* RawContextFactory::create_context(std::function&& code, smx_actor_t actor) +Context* RawContextFactory::create_context(std::function&& code, actor::ActorImpl* actor) { return this->new_context(std::move(code), actor, this); } // RawContext -RawContext::RawContext(std::function&& code, smx_actor_t actor, SwappedContextFactory* factory) +RawContext::RawContext(std::function&& code, actor::ActorImpl* actor, SwappedContextFactory* factory) : SwappedContext(std::move(code), actor, factory) { if (has_code()) { @@ -237,4 +237,6 @@ ContextFactory* raw_factory() XBT_VERB("Using raw contexts. Because the glibc is just not good enough for us."); return new RawContextFactory(); } -}}} +} // namespace context +} // namespace kernel +} // namespace simgrid diff --git a/src/kernel/context/ContextRaw.hpp b/src/kernel/context/ContextRaw.hpp index 074918050c..84c90553d0 100644 --- a/src/kernel/context/ContextRaw.hpp +++ b/src/kernel/context/ContextRaw.hpp @@ -26,7 +26,7 @@ namespace context { */ class RawContext : public SwappedContext { public: - RawContext(std::function&& code, smx_actor_t actor, SwappedContextFactory* factory); + RawContext(std::function&& code, actor::ActorImpl* actor, SwappedContextFactory* factory); void swap_into(SwappedContext* to) override; @@ -39,8 +39,10 @@ private: class RawContextFactory : public SwappedContextFactory { public: - Context* create_context(std::function&& code, smx_actor_t actor) override; + Context* create_context(std::function&& code, actor::ActorImpl* actor) override; }; -}}} // namespace +} // namespace context +} // namespace kernel +} // namespace simgrid #endif diff --git a/src/kernel/context/ContextThread.cpp b/src/kernel/context/ContextThread.cpp index 3e2b0668bd..d246a3c258 100644 --- a/src/kernel/context/ContextThread.cpp +++ b/src/kernel/context/ContextThread.cpp @@ -34,7 +34,7 @@ ThreadContextFactory::~ThreadContextFactory() ParallelThreadContext::finalize(); } -ThreadContext* ThreadContextFactory::create_context(std::function&& code, smx_actor_t actor, bool maestro) +ThreadContext* ThreadContextFactory::create_context(std::function&& code, actor::ActorImpl* actor, bool maestro) { if (parallel_) return this->new_context(std::move(code), actor, maestro); @@ -55,7 +55,7 @@ void ThreadContextFactory::run_all() // ThreadContext -ThreadContext::ThreadContext(std::function&& code, smx_actor_t actor, bool maestro) +ThreadContext::ThreadContext(std::function&& code, actor::ActorImpl* actor, bool maestro) : AttachContext(std::move(code), actor), is_maestro_(maestro) { /* If the user provided a function for the actor then use it */ @@ -227,4 +227,6 @@ XBT_PRIVATE ContextFactory* thread_factory() XBT_VERB("Activating thread context factory"); return new ThreadContextFactory(); } -}}} // namespace +} // namespace context +} // namespace kernel +} // namespace simgrid diff --git a/src/kernel/context/ContextThread.hpp b/src/kernel/context/ContextThread.hpp index 63cf956a38..720e54b229 100644 --- a/src/kernel/context/ContextThread.hpp +++ b/src/kernel/context/ContextThread.hpp @@ -20,7 +20,7 @@ namespace context { class XBT_PUBLIC ThreadContext : public AttachContext { public: - ThreadContext(std::function&& code, smx_actor_t actor, bool maestro); + ThreadContext(std::function&& code, actor::ActorImpl* actor, bool maestro); ThreadContext(const ThreadContext&) = delete; ThreadContext& operator=(const ThreadContext&) = delete; ~ThreadContext() override; @@ -53,7 +53,7 @@ private: class XBT_PUBLIC SerialThreadContext : public ThreadContext { public: - SerialThreadContext(std::function&& code, smx_actor_t actor, bool maestro) + SerialThreadContext(std::function&& code, actor::ActorImpl* actor, bool maestro) : ThreadContext(std::move(code), actor, maestro) { } @@ -63,7 +63,7 @@ public: class ParallelThreadContext : public ThreadContext { public: - ParallelThreadContext(std::function&& code, smx_actor_t actor, bool maestro) + ParallelThreadContext(std::function&& code, actor::ActorImpl* actor, bool maestro) : ThreadContext(std::move(code), actor, maestro) { } @@ -85,7 +85,7 @@ public: ThreadContextFactory(const ThreadContextFactory&) = delete; ThreadContextFactory& operator=(const ThreadContextFactory&) = delete; ~ThreadContextFactory() override; - ThreadContext* create_context(std::function&& code, smx_actor_t actor) override + ThreadContext* create_context(std::function&& code, actor::ActorImpl* actor) override { bool maestro = not code; return create_context(std::move(code), actor, maestro); @@ -93,8 +93,11 @@ public: void run_all() override; // Optional methods: - ThreadContext* attach(smx_actor_t actor) override { return create_context(std::function(), actor, false); } - ThreadContext* create_maestro(std::function&& code, smx_actor_t actor) override + ThreadContext* attach(actor::ActorImpl* actor) override + { + return create_context(std::function(), actor, false); + } + ThreadContext* create_maestro(std::function&& code, actor::ActorImpl* actor) override { return create_context(std::move(code), actor, true); } @@ -102,8 +105,10 @@ public: private: bool parallel_; - ThreadContext* create_context(std::function&& code, smx_actor_t actor, bool maestro); + ThreadContext* create_context(std::function&& code, actor::ActorImpl* actor, bool maestro); }; -}}} // namespace +} // namespace context +} // namespace kernel +} // namespace simgrid #endif diff --git a/src/kernel/context/ContextUnix.cpp b/src/kernel/context/ContextUnix.cpp index 77b952e594..9bae6d2710 100644 --- a/src/kernel/context/ContextUnix.cpp +++ b/src/kernel/context/ContextUnix.cpp @@ -56,7 +56,7 @@ namespace kernel { namespace context { // UContextFactory -Context* UContextFactory::create_context(std::function&& code, smx_actor_t actor) +Context* UContextFactory::create_context(std::function&& code, actor::ActorImpl* actor) { return new_context(std::move(code), actor, this); } @@ -64,7 +64,7 @@ Context* UContextFactory::create_context(std::function&& code, smx_actor // UContext -UContext::UContext(std::function&& code, smx_actor_t actor, SwappedContextFactory* factory) +UContext::UContext(std::function&& code, actor::ActorImpl* actor, SwappedContextFactory* factory) : SwappedContext(std::move(code), actor, factory) { /* if the user provided a function for the actor then use it. If not, nothing to do for maestro. */ @@ -105,4 +105,6 @@ XBT_PRIVATE ContextFactory* sysv_factory() XBT_VERB("Activating SYSV context factory"); return new UContextFactory(); } -}}} // namespace simgrid::kernel::context +} // namespace context +} // namespace kernel +} // namespace simgrid diff --git a/src/kernel/context/ContextUnix.hpp b/src/kernel/context/ContextUnix.hpp index 96a19143c9..ac12cc8481 100644 --- a/src/kernel/context/ContextUnix.hpp +++ b/src/kernel/context/ContextUnix.hpp @@ -25,7 +25,7 @@ namespace context { class UContext : public SwappedContext { public: - UContext(std::function&& code, smx_actor_t actor, SwappedContextFactory* factory); + UContext(std::function&& code, actor::ActorImpl* actor, SwappedContextFactory* factory); void swap_into(SwappedContext* to) override; @@ -35,8 +35,10 @@ private: class UContextFactory : public SwappedContextFactory { public: - Context* create_context(std::function&& code, smx_actor_t actor) override; + Context* create_context(std::function&& code, actor::ActorImpl* actor) override; }; -}}} // namespace +} // namespace context +} // namespace kernel +} // namespace simgrid #endif diff --git a/src/mc/mc_base.cpp b/src/mc/mc_base.cpp index 299dbdedcd..a99957ca21 100644 --- a/src/mc/mc_base.cpp +++ b/src/mc/mc_base.cpp @@ -117,9 +117,9 @@ bool actor_is_enabled(smx_actor_t actor) case SIMCALL_MUTEX_LOCK: { smx_mutex_t mutex = simcall_mutex_lock__get__mutex(req); - if (mutex->owner == nullptr) + if (mutex->owner_ == nullptr) return true; - return mutex->owner->get_pid() == req->issuer->get_pid(); + return mutex->owner_->get_pid() == req->issuer->get_pid(); } case SIMCALL_SEM_ACQUIRE: { diff --git a/src/mc/mc_request.cpp b/src/mc/mc_request.cpp index 18c40141c3..c1bd140ee9 100644 --- a/src/mc/mc_request.cpp +++ b/src/mc/mc_request.cpp @@ -339,9 +339,9 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid : simcall_mutex_trylock__get__mutex(req) )); args = bprintf( - "locked = %d, owner = %d, sleeping = n/a", mutex.getBuffer()->locked, - mutex.getBuffer()->owner != nullptr - ? (int)mc_model_checker->process().resolveActor(simgrid::mc::remote(mutex.getBuffer()->owner))->get_pid() + "locked = %d, owner = %d, sleeping = n/a", mutex.getBuffer()->locked_, + mutex.getBuffer()->owner_ != nullptr + ? (int)mc_model_checker->process().resolveActor(simgrid::mc::remote(mutex.getBuffer()->owner_))->get_pid() : -1); break; }