From: Frederic Suter Date: Thu, 28 Nov 2019 12:35:19 +0000 (+0100) Subject: e_smx_state_t is now kernel::activity::State X-Git-Tag: v3.25~356 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3ea82f7e0ddd6a4582aecee0f0e4662664605f61 e_smx_state_t is now kernel::activity::State --- diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index 08cdf5b428..b6a2b5ceca 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -98,6 +98,7 @@ typedef boost::intrusive_ptr ActorImplPtr; namespace activity { class ActivityImpl; + enum class State; typedef boost::intrusive_ptr ActivityImplPtr; XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity); XBT_PUBLIC void intrusive_ptr_release(ActivityImpl* activity); @@ -198,7 +199,7 @@ typedef simgrid::kernel::activity::ConditionVariableImpl* smx_cond_t; typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t; typedef simgrid::kernel::activity::MutexImpl* smx_mutex_t; typedef simgrid::kernel::activity::SemaphoreImpl* smx_sem_t; - +typedef simgrid::kernel::activity::State e_smx_state_t; #else typedef struct s4u_Actor s4u_Actor; @@ -214,6 +215,7 @@ typedef struct s4u_Storage s4u_Storage; typedef struct s4u_NetZone s4u_NetZone; typedef struct s4u_VM s4u_VM; typedef struct kernel_Activity* smx_activity_t; +typedef enum kernel_activity_state e_smx_state_t; typedef struct s_smx_timer* smx_timer_t; typedef struct s_smx_actor* smx_actor_t; diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 0b4c7152e0..f9d074597f 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -17,35 +17,6 @@ #include #endif -/* ******************************** Host ************************************ */ -/** @brief Host datatype - @ingroup simix_host_management - - A location (or host) is any possible place where - a process may run. Thus it is represented as a physical - resource with computing capabilities, some mailboxes - to enable running process to communicate with remote ones, and - some private data that can be only accessed by local - process. - - @see m_host_management - @{ */ -typedef enum { - SIMIX_WAITING, - SIMIX_READY, - SIMIX_RUNNING, - SIMIX_DONE, - SIMIX_CANCELED, - SIMIX_FAILED, - SIMIX_SRC_HOST_FAILURE, - SIMIX_DST_HOST_FAILURE, - SIMIX_TIMEOUT, - SIMIX_SRC_TIMEOUT, - SIMIX_DST_TIMEOUT, - SIMIX_LINK_FAILURE -} e_smx_state_t; -/** @} */ - /******************************* Networking ***********************************/ extern unsigned smx_context_stack_size; extern unsigned smx_context_guard_size; diff --git a/src/kernel/activity/ActivityImpl.cpp b/src/kernel/activity/ActivityImpl.cpp index 30278792ec..240631100b 100644 --- a/src/kernel/activity/ActivityImpl.cpp +++ b/src/kernel/activity/ActivityImpl.cpp @@ -60,7 +60,7 @@ void ActivityImpl::cancel() XBT_VERB("Activity %p is canceled", this); if (surf_action_ != nullptr) surf_action_->cancel(); - state_ = SIMIX_CANCELED; + state_ = State::CANCELED; } // boost::intrusive_ptr support: diff --git a/src/kernel/activity/ActivityImpl.hpp b/src/kernel/activity/ActivityImpl.hpp index f9532eb13f..cd98b6ad2c 100644 --- a/src/kernel/activity/ActivityImpl.hpp +++ b/src/kernel/activity/ActivityImpl.hpp @@ -19,13 +19,27 @@ namespace simgrid { namespace kernel { namespace activity { +enum class State { + WAITING = 0, + READY, + RUNNING, + DONE, + CANCELED, + FAILED, + SRC_HOST_FAILURE, + DST_HOST_FAILURE, + TIMEOUT, + SRC_TIMEOUT, + DST_TIMEOUT, + LINK_FAILURE +}; class XBT_PUBLIC ActivityImpl { std::atomic_int_fast32_t refcount_{0}; public: virtual ~ActivityImpl(); ActivityImpl() = default; - e_smx_state_t state_ = SIMIX_WAITING; /* State of the activity */ + State state_ = State::WAITING; /* State of the activity */ std::list simcalls_; /* List of simcalls waiting for this activity */ resource::Action* surf_action_ = nullptr; diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 9a3a339af3..769c8e660c 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -57,7 +57,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend( if (mbox->permanent_receiver_ != nullptr) { // this mailbox is for small messages, which have to be sent right now - other_comm->state_ = SIMIX_READY; + other_comm->state_ = simgrid::kernel::activity::State::READY; other_comm->dst_actor_ = mbox->permanent_receiver_.get(); mbox->done_comm_queue_.push_back(other_comm); XBT_DEBUG("pushing a message into the permanent receive list %p, comm %p", mbox, other_comm.get()); @@ -68,7 +68,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend( } else { XBT_DEBUG("Receive already pushed"); - other_comm->state_ = SIMIX_READY; + other_comm->state_ = simgrid::kernel::activity::State::READY; other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::READY); } @@ -89,7 +89,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend( other_comm->copy_data_fun = copy_data_fun; if (MC_is_active() || MC_record_replay_is_active()) - other_comm->state_ = SIMIX_RUNNING; + other_comm->state_ = simgrid::kernel::activity::State::RUNNING; else other_comm->start(); @@ -136,7 +136,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_irecv( } else { if (other_comm->surf_action_ && other_comm->get_remaining() < 1e-12) { XBT_DEBUG("comm %p has been already sent, and is finished, destroy it", other_comm.get()); - other_comm->state_ = SIMIX_DONE; + other_comm->state_ = simgrid::kernel::activity::State::DONE; other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::DONE).set_mailbox(nullptr); } } @@ -158,7 +158,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_irecv( } else { XBT_DEBUG("Match my %p with the existing %p", this_synchro.get(), other_comm.get()); - other_comm->state_ = SIMIX_READY; + other_comm->state_ = simgrid::kernel::activity::State::READY; other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::READY); } receiver->comms.push_back(other_comm); @@ -176,7 +176,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_irecv( other_comm->copy_data_fun = copy_data_fun; if (MC_is_active() || MC_record_replay_is_active()) { - other_comm->state_ = SIMIX_RUNNING; + other_comm->state_ = simgrid::kernel::activity::State::RUNNING; return other_comm; } other_comm->start(); @@ -193,7 +193,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, simgrid::kernel::activity: if (MC_is_active() || MC_record_replay_is_active()) { int idx = SIMCALL_GET_MC_VALUE(*simcall); if (idx == 0) { - comm->state_ = SIMIX_DONE; + comm->state_ = simgrid::kernel::activity::State::DONE; } else { /* If we reached this point, the wait simcall must have a timeout */ /* Otherwise it shouldn't be enabled and executed by the MC */ @@ -201,9 +201,9 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, simgrid::kernel::activity: THROW_IMPOSSIBLE; if (comm->src_actor_ == simcall->issuer_) - comm->state_ = SIMIX_SRC_TIMEOUT; + comm->state_ = simgrid::kernel::activity::State::SRC_TIMEOUT; else - comm->state_ = SIMIX_DST_TIMEOUT; + comm->state_ = simgrid::kernel::activity::State::DST_TIMEOUT; } comm->finish(); @@ -212,7 +212,8 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, simgrid::kernel::activity: /* If the synchro has already finish perform the error handling, */ /* otherwise set up a waiting timeout on the right side */ - if (comm->state_ != SIMIX_WAITING && comm->state_ != SIMIX_RUNNING) { + if (comm->state_ != simgrid::kernel::activity::State::WAITING && + comm->state_ != simgrid::kernel::activity::State::RUNNING) { comm->finish(); } else { /* we need a sleep action (even when there is no timeout) to be notified of host failures */ simgrid::kernel::resource::Action* sleep = simcall->issuer_->get_host()->pimpl_cpu->sleep(timeout); @@ -232,9 +233,10 @@ void simcall_HANDLER_comm_test(smx_simcall_t simcall, simgrid::kernel::activity: if (MC_is_active() || MC_record_replay_is_active()) { res = comm->src_actor_ && comm->dst_actor_; if (res) - comm->state_ = SIMIX_DONE; + comm->state_ = simgrid::kernel::activity::State::DONE; } else { - res = comm->state_ != SIMIX_WAITING && comm->state_ != SIMIX_RUNNING; + res = comm->state_ != simgrid::kernel::activity::State::WAITING && + comm->state_ != simgrid::kernel::activity::State::RUNNING; } simcall_comm_test__set__result(simcall, res); @@ -260,7 +262,7 @@ void simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activi simgrid::kernel::activity::CommImpl* comm = comms[idx]; simcall_comm_testany__set__result(simcall, idx); comm->simcalls_.push_back(simcall); - comm->state_ = SIMIX_DONE; + comm->state_ = simgrid::kernel::activity::State::DONE; comm->finish(); } return; @@ -268,7 +270,8 @@ void simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activi for (std::size_t i = 0; i != count; ++i) { simgrid::kernel::activity::CommImpl* comm = comms[i]; - if (comm->state_ != SIMIX_WAITING && comm->state_ != SIMIX_RUNNING) { + if (comm->state_ != simgrid::kernel::activity::State::WAITING && + comm->state_ != simgrid::kernel::activity::State::RUNNING) { simcall_comm_testany__set__result(simcall, i); comm->simcalls_.push_back(simcall); comm->finish(); @@ -301,7 +304,7 @@ void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, simgrid::kernel::activi auto* comm = comms[idx]; comm->simcalls_.push_back(simcall); simcall_comm_waitany__set__result(simcall, idx); - comm->state_ = SIMIX_DONE; + comm->state_ = simgrid::kernel::activity::State::DONE; comm->finish(); return; } @@ -322,7 +325,8 @@ void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, simgrid::kernel::activi comm->simcalls_.push_back(simcall); /* see if the synchro is already finished */ - if (comm->state_ != SIMIX_WAITING && comm->state_ != SIMIX_RUNNING) { + if (comm->state_ != simgrid::kernel::activity::State::WAITING && + comm->state_ != simgrid::kernel::activity::State::RUNNING) { comm->finish(); break; } @@ -410,7 +414,7 @@ CommImpl::~CommImpl() cleanupSurf(); - if (detached_ && state_ != SIMIX_DONE) { + if (detached_ && state_ != State::DONE) { /* the communication has failed and was detached: * we have to free the buffer */ if (clean_fun) @@ -425,7 +429,7 @@ CommImpl::~CommImpl() CommImpl* CommImpl::start() { /* If both the sender and the receiver are already there, start the communication */ - if (state_ == SIMIX_READY) { + if (state_ == State::READY) { s4u::Host* sender = src_actor_->get_host(); s4u::Host* receiver = dst_actor_->get_host(); @@ -433,7 +437,7 @@ CommImpl* CommImpl::start() surf_action_ = surf_network_model->communicate(sender, receiver, size_, rate_); surf_action_->set_activity(this); surf_action_->set_category(get_tracing_category()); - state_ = SIMIX_RUNNING; + state_ = State::RUNNING; XBT_DEBUG("Starting communication %p from '%s' to '%s' (surf_action: %p)", this, sender->get_cname(), receiver->get_cname(), surf_action_); @@ -442,7 +446,7 @@ CommImpl* CommImpl::start() if (surf_action_->get_state() == resource::Action::State::FAILED) { XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure", sender->get_cname(), receiver->get_cname()); - state_ = SIMIX_LINK_FAILURE; + state_ = State::LINK_FAILURE; post(); } else if (src_actor_->is_suspended() || dst_actor_->is_suspended()) { @@ -515,13 +519,13 @@ void CommImpl::resume() void CommImpl::cancel() { /* if the synchro is a waiting state means that it is still in a mbox so remove from it and delete it */ - if (state_ == SIMIX_WAITING) { + if (state_ == State::WAITING) { if (not detached_) { mbox_->remove(this); - state_ = SIMIX_CANCELED; + state_ = State::CANCELED; } } else if (not MC_is_active() /* when running the MC there are no surf actions */ - && not MC_record_replay_is_active() && (state_ == SIMIX_READY || state_ == SIMIX_RUNNING)) { + && not MC_record_replay_is_active() && (state_ == State::READY || state_ == State::RUNNING)) { surf_action_->cancel(); } } @@ -546,17 +550,17 @@ void CommImpl::post() { /* Update synchro state */ if (src_timeout_ && src_timeout_->get_state() == resource::Action::State::FINISHED) - state_ = SIMIX_SRC_TIMEOUT; + state_ = State::SRC_TIMEOUT; else if (dst_timeout_ && dst_timeout_->get_state() == resource::Action::State::FINISHED) - state_ = SIMIX_DST_TIMEOUT; + state_ = State::DST_TIMEOUT; else if (src_timeout_ && src_timeout_->get_state() == resource::Action::State::FAILED) - state_ = SIMIX_SRC_HOST_FAILURE; + state_ = State::SRC_HOST_FAILURE; else if (dst_timeout_ && dst_timeout_->get_state() == resource::Action::State::FAILED) - state_ = SIMIX_DST_HOST_FAILURE; + state_ = State::DST_HOST_FAILURE; else if (surf_action_ && surf_action_->get_state() == resource::Action::State::FAILED) { - state_ = SIMIX_LINK_FAILURE; + state_ = State::LINK_FAILURE; } else - state_ = SIMIX_DONE; + state_ = State::DONE; XBT_DEBUG("SIMIX_post_comm: comm %p, state %d, src_proc %p, dst_proc %p, detached: %d", this, (int)state_, src_actor_.get(), dst_actor_.get(), detached_); @@ -608,22 +612,22 @@ void CommImpl::finish() } else { switch (state_) { - case SIMIX_DONE: + case State::DONE: XBT_DEBUG("Communication %p complete!", this); copy_data(); break; - case SIMIX_SRC_TIMEOUT: + case State::SRC_TIMEOUT: simcall->issuer_->exception_ = std::make_exception_ptr( simgrid::TimeoutException(XBT_THROW_POINT, "Communication timeouted because of the sender")); break; - case SIMIX_DST_TIMEOUT: + case State::DST_TIMEOUT: simcall->issuer_->exception_ = std::make_exception_ptr( simgrid::TimeoutException(XBT_THROW_POINT, "Communication timeouted because of the receiver")); break; - case SIMIX_SRC_HOST_FAILURE: + case State::SRC_HOST_FAILURE: if (simcall->issuer_ == src_actor_) simcall->issuer_->context_->iwannadie = true; else @@ -631,7 +635,7 @@ void CommImpl::finish() std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Remote peer failed")); break; - case SIMIX_DST_HOST_FAILURE: + case State::DST_HOST_FAILURE: if (simcall->issuer_ == dst_actor_) simcall->issuer_->context_->iwannadie = true; else @@ -639,7 +643,7 @@ void CommImpl::finish() std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Remote peer failed")); break; - case SIMIX_LINK_FAILURE: + case State::LINK_FAILURE: XBT_DEBUG("Link failure in synchro %p between '%s' and '%s': posting an exception to the issuer: %s (%p) " "detached:%d", this, src_actor_ ? src_actor_->get_host()->get_cname() : nullptr, @@ -656,7 +660,7 @@ void CommImpl::finish() std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Link failure"))); break; - case SIMIX_CANCELED: + case State::CANCELED: if (simcall->issuer_ == dst_actor_) simcall->issuer_->exception_ = std::make_exception_ptr( simgrid::CancelException(XBT_THROW_POINT, "Communication canceled by the sender")); diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index 7c899d4b0a..eda2b58c9f 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -26,19 +26,20 @@ void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::acti /* set surf's synchro */ if (MC_is_active() || MC_record_replay_is_active()) { - synchro->state_ = SIMIX_DONE; + synchro->state_ = simgrid::kernel::activity::State::DONE; synchro->finish(); return; } /* If the synchro is already finished then perform the error handling */ - if (synchro->state_ != SIMIX_RUNNING) + if (synchro->state_ != simgrid::kernel::activity::State::RUNNING) synchro->finish(); } void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro) { - bool res = (synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING); + bool res = (synchro->state_ != simgrid::kernel::activity::State::WAITING && + synchro->state_ != simgrid::kernel::activity::State::RUNNING); if (res) { synchro->simcalls_.push_back(simcall); synchro->finish(); @@ -73,7 +74,8 @@ void simcall_HANDLER_execution_waitany_for(smx_simcall_t simcall, simgrid::kerne exec->simcalls_.push_back(simcall); /* see if the synchro is already finished */ - if (exec->state_ != SIMIX_WAITING && exec->state_ != SIMIX_RUNNING) { + if (exec->state_ != simgrid::kernel::activity::State::WAITING && + exec->state_ != simgrid::kernel::activity::State::RUNNING) { exec->finish(); break; } @@ -137,7 +139,7 @@ ExecImpl& ExecImpl::set_bytes_amounts(const std::vector& bytes_amounts) ExecImpl* ExecImpl::start() { - state_ = SIMIX_RUNNING; + state_ = State::RUNNING; if (not MC_is_active() && not MC_record_replay_is_active()) { if (hosts_.size() == 1) { surf_action_ = hosts_.front()->pimpl_cpu->execution_start(flops_amounts_.front()); @@ -184,14 +186,14 @@ void ExecImpl::post() if (hosts_.size() == 1 && not hosts_.front()->is_on()) { /* FIXME: handle resource failure for parallel tasks too */ /* If the host running the synchro failed, notice it. This way, the asking * process can be killed if it runs on that host itself */ - state_ = SIMIX_FAILED; + state_ = State::FAILED; } else if (surf_action_ && surf_action_->get_state() == resource::Action::State::FAILED) { /* If the host running the synchro didn't fail, then the synchro was canceled */ - state_ = SIMIX_CANCELED; + state_ = State::CANCELED; } else if (timeout_detector_ && timeout_detector_->get_state() == resource::Action::State::FINISHED) { - state_ = SIMIX_TIMEOUT; + state_ = State::TIMEOUT; } else { - state_ = SIMIX_DONE; + state_ = State::DONE; } clean_action(); @@ -243,12 +245,12 @@ void ExecImpl::finish() switch (state_) { - case SIMIX_DONE: + case State::DONE: /* do nothing, synchro done */ XBT_DEBUG("ExecImpl::finish(): execution successful"); break; - case SIMIX_FAILED: + case State::FAILED: XBT_DEBUG("ExecImpl::finish(): host '%s' failed", simcall->issuer_->get_host()->get_cname()); simcall->issuer_->context_->iwannadie = true; if (simcall->issuer_->get_host()->is_on()) @@ -257,13 +259,13 @@ void ExecImpl::finish() /* else, the actor will be killed with no possibility to survive */ break; - case SIMIX_CANCELED: + case State::CANCELED: XBT_DEBUG("ExecImpl::finish(): execution canceled"); simcall->issuer_->exception_ = std::make_exception_ptr(simgrid::CancelException(XBT_THROW_POINT, "Execution Canceled")); break; - case SIMIX_TIMEOUT: + case State::TIMEOUT: XBT_DEBUG("ExecImpl::finish(): execution timeouted"); simcall->issuer_->exception_ = std::make_exception_ptr(simgrid::TimeoutException(XBT_THROW_POINT, "Timeouted")); break; diff --git a/src/kernel/activity/IoImpl.cpp b/src/kernel/activity/IoImpl.cpp index 63f5381293..783616f9b8 100644 --- a/src/kernel/activity/IoImpl.cpp +++ b/src/kernel/activity/IoImpl.cpp @@ -22,10 +22,10 @@ void simcall_HANDLER_io_wait(smx_simcall_t simcall, simgrid::kernel::activity::I synchro->register_simcall(simcall); if (MC_is_active() || MC_record_replay_is_active()) - synchro->state_ = SIMIX_DONE; + synchro->state_ = simgrid::kernel::activity::State::DONE; /* If the synchro is already finished then perform the error handling */ - if (synchro->state_ != SIMIX_RUNNING) + if (synchro->state_ != simgrid::kernel::activity::State::RUNNING) synchro->finish(); } @@ -59,7 +59,7 @@ IoImpl& IoImpl::set_storage(resource::StorageImpl* storage) IoImpl* IoImpl::start() { - state_ = SIMIX_RUNNING; + state_ = State::RUNNING; if (storage_) surf_action_ = storage_->io_start(size_, type_); else @@ -77,11 +77,11 @@ void IoImpl::post() performed_ioops_ = surf_action_->get_cost(); if (surf_action_->get_state() == resource::Action::State::FAILED) { if ((storage_ && not storage_->is_on()) || (disk_ && not disk_->is_on())) - state_ = SIMIX_FAILED; + state_ = State::FAILED; else - state_ = SIMIX_CANCELED; + state_ = State::CANCELED; } else if (surf_action_->get_state() == resource::Action::State::FINISHED) { - state_ = SIMIX_DONE; + state_ = State::DONE; } on_completion(*this); @@ -95,15 +95,15 @@ void IoImpl::finish() smx_simcall_t simcall = simcalls_.front(); simcalls_.pop_front(); switch (state_) { - case SIMIX_DONE: + case State::DONE: /* do nothing, synchro done */ break; - case SIMIX_FAILED: + case State::FAILED: simcall->issuer_->context_->iwannadie = true; simcall->issuer_->exception_ = std::make_exception_ptr(StorageFailureException(XBT_THROW_POINT, "Storage failed")); break; - case SIMIX_CANCELED: + case State::CANCELED: simcall->issuer_->exception_ = std::make_exception_ptr(CancelException(XBT_THROW_POINT, "I/O Canceled")); break; default: diff --git a/src/kernel/activity/SleepImpl.cpp b/src/kernel/activity/SleepImpl.cpp index dc94cffb13..8a3eb18588 100644 --- a/src/kernel/activity/SleepImpl.cpp +++ b/src/kernel/activity/SleepImpl.cpp @@ -42,11 +42,11 @@ void SleepImpl::post() { if (surf_action_->get_state() == resource::Action::State::FAILED) { if (host_ && not host_->is_on()) - state_ = SIMIX_SRC_HOST_FAILURE; + state_ = State::SRC_HOST_FAILURE; else - state_ = SIMIX_CANCELED; + state_ = State::CANCELED; } else if (surf_action_->get_state() == resource::Action::State::FINISHED) { - state_ = SIMIX_DONE; + state_ = State::DONE; } /* Answer all simcalls associated with the synchro */ finish(); diff --git a/src/kernel/activity/SynchroRaw.cpp b/src/kernel/activity/SynchroRaw.cpp index 62c12314e4..8a4cb51ea0 100644 --- a/src/kernel/activity/SynchroRaw.cpp +++ b/src/kernel/activity/SynchroRaw.cpp @@ -57,9 +57,9 @@ void RawImpl::cancel() void RawImpl::post() { if (surf_action_->get_state() == resource::Action::State::FAILED) { - state_ = SIMIX_FAILED; + state_ = State::FAILED; } else if (surf_action_->get_state() == resource::Action::State::FINISHED) { - state_ = SIMIX_SRC_TIMEOUT; + state_ = State::SRC_TIMEOUT; } finish(); } @@ -69,11 +69,11 @@ void RawImpl::finish() smx_simcall_t simcall = simcalls_.front(); simcalls_.pop_front(); - if (state_ == SIMIX_FAILED) { + if (state_ == State::FAILED) { XBT_DEBUG("RawImpl::finish(): host '%s' failed", simcall->issuer_->get_host()->get_cname()); simcall->issuer_->context_->iwannadie = true; simcall->issuer_->exception_ = std::make_exception_ptr(HostFailureException(XBT_THROW_POINT, "Host failed")); - } else if (state_ != SIMIX_SRC_TIMEOUT) { + } else if (state_ != State::SRC_TIMEOUT) { xbt_die("Internal error in RawImpl::finish() unexpected synchro state %d", static_cast(state_)); } diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 6cea03b393..1db9c0dbaa 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -196,7 +196,7 @@ void ActorImpl::exit() /* destroy the blocking synchro if any */ if (waiting_synchro != nullptr) { waiting_synchro->cancel(); - waiting_synchro->state_ = SIMIX_FAILED; + waiting_synchro->state_ = activity::State::FAILED; activity::ExecImplPtr exec = boost::dynamic_pointer_cast(waiting_synchro); activity::CommImplPtr comm = boost::dynamic_pointer_cast(waiting_synchro); diff --git a/src/plugins/host_load.cpp b/src/plugins/host_load.cpp index 3885580d25..f84ffc0404 100644 --- a/src/plugins/host_load.cpp +++ b/src/plugins/host_load.cpp @@ -130,15 +130,14 @@ void HostLoad::update() auto current_iter = iter; ++iter; - if (action != nullptr && action->get_finish_time() != now && activity->state_ == e_smx_state_t::SIMIX_RUNNING) { + if (action != nullptr && action->get_finish_time() != now && activity->state_ == kernel::activity::State::RUNNING) { if (remaining_cost_after_last_update == activity_uninitialized_remaining_cost) { remaining_cost_after_last_update = action->get_cost(); } double computed_flops_since_last_update = remaining_cost_after_last_update - /*remaining now*/activity->get_remaining(); computed_flops_ += computed_flops_since_last_update; remaining_cost_after_last_update = activity->get_remaining(); - } - else if (activity->state_ == e_smx_state_t::SIMIX_DONE) { + } else if (activity->state_ == kernel::activity::State::DONE) { computed_flops_ += remaining_cost_after_last_update; current_activities.erase(current_iter); } diff --git a/src/s4u/s4u_Comm.cpp b/src/s4u/s4u_Comm.cpp index 98965dc78c..9b9ac8bbf2 100644 --- a/src/s4u/s4u_Comm.cpp +++ b/src/s4u/s4u_Comm.cpp @@ -20,10 +20,11 @@ xbt::signal Comm::on_completion; Comm::~Comm() { - if (state_ == State::STARTED && not detached_ && (pimpl_ == nullptr || pimpl_->state_ == SIMIX_RUNNING)) { + if (state_ == State::STARTED && not detached_ && + (pimpl_ == nullptr || pimpl_->state_ == kernel::activity::State::RUNNING)) { XBT_INFO("Comm %p freed before its completion. Detached: %d, State: %d", this, detached_, (int)state_); if (pimpl_ != nullptr) - XBT_INFO("pimpl_->state: %d", pimpl_->state_); + XBT_INFO("pimpl_->state: %d", static_cast(pimpl_->state_)); else XBT_INFO("pimpl_ is null"); xbt_backtrace_display_current(); diff --git a/src/s4u/s4u_Mailbox.cpp b/src/s4u/s4u_Mailbox.cpp index d9d6c6c97b..d9b5410553 100644 --- a/src/s4u/s4u_Mailbox.cpp +++ b/src/s4u/s4u_Mailbox.cpp @@ -48,10 +48,10 @@ bool Mailbox::ready() { bool comm_ready = false; if (not pimpl_->comm_queue_.empty()) { - comm_ready = pimpl_->comm_queue_.front()->state_ == SIMIX_DONE; - + comm_ready = pimpl_->comm_queue_.front()->state_ == kernel::activity::State::DONE; + } else if (pimpl_->permanent_receiver_ && not pimpl_->done_comm_queue_.empty()) { - comm_ready = pimpl_->done_comm_queue_.front()->state_ == SIMIX_DONE; + comm_ready = pimpl_->done_comm_queue_.front()->state_ == kernel::activity::State::DONE; } return comm_ready; } diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 387fd23dc6..257a157be3 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -57,7 +57,7 @@ void simcall_process_suspend(smx_actor_t process) // XBT_DEPRECATED_v328 e_smx_state_t simcall_process_sleep(double duration) // XBT_DEPRECATED_v329 { SIMIX_process_self()->sleep(duration); - return SIMIX_DONE; + return simgrid::kernel::activity::State::DONE; } /**