X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b7c53df18dcbf388f0dce6d7baa3086436028313..255700918582111f0aacaa7b7fed87dcedc1a840:/src/kernel/activity/IoImpl.cpp diff --git a/src/kernel/activity/IoImpl.cpp b/src/kernel/activity/IoImpl.cpp index cb274dcdb6..a6dcf3ae78 100644 --- a/src/kernel/activity/IoImpl.cpp +++ b/src/kernel/activity/IoImpl.cpp @@ -13,9 +13,9 @@ #include "src/kernel/actor/ActorImpl.hpp" #include "src/kernel/actor/SimcallObserver.hpp" #include "src/kernel/context/Context.hpp" +#include "src/kernel/resource/CpuImpl.hpp" #include "src/kernel/resource/DiskImpl.hpp" #include "src/mc/mc_replay.hpp" -#include "src/surf/cpu_interface.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)"); @@ -26,6 +26,24 @@ namespace activity { IoImpl::IoImpl() { piface_ = new s4u::Io(this); + actor::ActorImpl* self = actor::ActorImpl::self(); + if (self) { + actor_ = self; + self->activities_.emplace_back(this); + } +} + +IoImpl& IoImpl::set_sharing_penalty(double sharing_penalty) +{ + sharing_penalty_ = sharing_penalty; + return *this; +} + +IoImpl& IoImpl::update_sharing_penalty(double sharing_penalty) +{ + sharing_penalty_ = sharing_penalty; + surf_action_->set_sharing_penalty(sharing_penalty); + return *this; } IoImpl& IoImpl::set_timeout(double timeout) @@ -59,6 +77,7 @@ IoImpl* IoImpl::start() state_ = State::RUNNING; surf_action_ = disk_->get_host()->get_netpoint()->get_englobing_zone()->get_disk_model()->io_start(disk_, size_, type_); + surf_action_->set_sharing_penalty(sharing_penalty_); surf_action_->set_activity(this); XBT_DEBUG("Create IO synchro %p %s", this, get_cname()); @@ -94,6 +113,25 @@ void IoImpl::post() /* Answer all simcalls associated with the synchro */ finish(); } +void IoImpl::set_exception(actor::ActorImpl* issuer) +{ + switch (state_) { + case State::FAILED: + issuer->context_->set_wannadie(); + piface_->complete(s4u::Activity::State::FAILED); + issuer->exception_ = std::make_exception_ptr(StorageFailureException(XBT_THROW_POINT, "Storage failed")); + break; + case State::CANCELED: + issuer->exception_ = std::make_exception_ptr(CancelException(XBT_THROW_POINT, "I/O Canceled")); + break; + case State::TIMEOUT: + issuer->exception_ = std::make_exception_ptr(TimeoutException(XBT_THROW_POINT, "Timeouted")); + break; + default: + xbt_assert(state_ == State::DONE, "Internal error in IoImpl::finish(): unexpected synchro state %s", + to_c_str(state_)); + } +} void IoImpl::finish() { @@ -127,23 +165,7 @@ void IoImpl::finish() } } - switch (state_) { - case State::FAILED: - simcall->issuer_->context_->set_wannadie(); - piface_->complete(s4u::Activity::State::FAILED); - simcall->issuer_->exception_ = - std::make_exception_ptr(StorageFailureException(XBT_THROW_POINT, "Storage failed")); - break; - case State::CANCELED: - simcall->issuer_->exception_ = std::make_exception_ptr(CancelException(XBT_THROW_POINT, "I/O Canceled")); - break; - case State::TIMEOUT: - simcall->issuer_->exception_ = std::make_exception_ptr(TimeoutException(XBT_THROW_POINT, "Timeouted")); - break; - default: - xbt_assert(state_ == State::DONE, "Internal error in IoImpl::finish(): unexpected synchro state %s", - to_c_str(state_)); - } + set_exception(simcall->issuer_); simcall->issuer_->waiting_synchro_ = nullptr; simcall->issuer_->simcall_answer();