#include <simgrid/Exception.hpp>
#include <simgrid/kernel/routing/NetPoint.hpp>
-#include <simgrid/s4u/Engine.hpp>
-#include <simgrid/s4u/Host.hpp>
-#include "mc/mc.h"
#include "src/kernel/activity/IoImpl.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
-#include "src/kernel/actor/SimcallObserver.hpp"
-#include "src/kernel/resource/CpuImpl.hpp"
#include "src/kernel/resource/DiskImpl.hpp"
#include "src/kernel/resource/HostImpl.hpp"
-#include "src/mc/mc_replay.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_io, kernel, "Kernel io-related synchronization");
return *this;
}
-IoImpl& IoImpl::set_timeout(double timeout)
-{
- const s4u::Host* host = get_disk()->get_host();
- timeout_detector_ = host->get_cpu()->sleep(timeout);
- timeout_detector_->set_activity(this);
- return *this;
-}
-
IoImpl& IoImpl::set_type(s4u::Io::OpType type)
{
type_ = type;
return this;
}
-void IoImpl::post()
-{
- performed_ioops_ = model_action_->get_cost();
- if (model_action_->get_state() == resource::Action::State::FAILED) {
- if (host_ && dst_host_) { // this is an I/O stream
- if (not host_->is_on())
- set_state(State::SRC_HOST_FAILURE);
- else if (not dst_host_->is_on())
- set_state(State::DST_HOST_FAILURE);
- } else if ((disk_ && not disk_->is_on()) || (dst_disk_ && not dst_disk_->is_on()))
- set_state(State::FAILED);
- else
- set_state(State::CANCELED);
- } else if (timeout_detector_ && timeout_detector_->get_state() == resource::Action::State::FINISHED &&
- model_action_->get_remains() > 0.0) {
- model_action_->set_state(resource::Action::State::FAILED);
- set_state(State::TIMEOUT);
- } else {
- set_state(State::DONE);
- }
-
- clean_action();
- if (timeout_detector_) {
- timeout_detector_->unref();
- timeout_detector_ = nullptr;
- }
-
- /* Answer all simcalls associated with the synchro */
- finish();
-}
void IoImpl::set_exception(actor::ActorImpl* issuer)
{
switch (get_state()) {
void IoImpl::finish()
{
XBT_DEBUG("IoImpl::finish() in state %s", get_state_str());
+ if (model_action_ != nullptr) {
+ performed_ioops_ = model_action_->get_cost();
+ if (model_action_->get_state() == resource::Action::State::FAILED) {
+ if (host_ && dst_host_) { // this is an I/O stream
+ if (not host_->is_on())
+ set_state(State::SRC_HOST_FAILURE);
+ else if (not dst_host_->is_on())
+ set_state(State::DST_HOST_FAILURE);
+ } else if ((disk_ && not disk_->is_on()) || (dst_disk_ && not dst_disk_->is_on()))
+ set_state(State::FAILED);
+ else
+ set_state(State::CANCELED);
+ } else {
+ set_state(State::DONE);
+ }
+
+ clean_action();
+ }
+
while (not simcalls_.empty()) {
actor::Simcall* simcall = simcalls_.front();
simcalls_.pop_front();