-/* 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. */
#include "DiskImpl.hpp"
#include "simgrid/s4u/Engine.hpp"
-#include "simgrid/sg_config.hpp"
#include "src/kernel/EngineImpl.hpp"
#include "src/kernel/lmm/maxmin.hpp"
#include "src/kernel/resource/profile/Profile.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_disk, ker_resource, "Disk resources, that fuel I/O activities");
-/***********
- * Options *
- ***********/
-static simgrid::config::Flag<std::string> cfg_disk_solver("disk/solver",
- "Set linear equations solver used by disk model", "maxmin",
- &simgrid::kernel::lmm::System::validate_solver);
-
-namespace simgrid {
-namespace kernel {
-namespace resource {
+namespace simgrid::kernel::resource {
xbt::signal<void(DiskAction const&, Action::State, Action::State)> DiskAction::on_state_change;
-/*********
- * Model *
- *********/
-
-DiskModel::DiskModel(const std::string& name) : Model(name)
-{
- set_maxmin_system(lmm::System::build(cfg_disk_solver, true /* selective update */));
-}
-
/************
* Resource *
************/
void DiskImpl::destroy()
{
s4u::Disk::on_destruction(piface_);
+ piface_.on_this_destruction(piface_);
delete this;
}
{
if (not is_on()) {
Resource::turn_on();
- s4u::Disk::on_state_change(piface_);
+ s4u::Disk::on_onoff(piface_);
+ piface_.on_this_onoff(piface_);
}
}
void DiskImpl::turn_off()
{
if (is_on()) {
Resource::turn_off();
- s4u::Disk::on_state_change(piface_);
+ s4u::Disk::on_onoff(piface_);
+ piface_.on_this_onoff(piface_);
+
+ const kernel::lmm::Element* elem = nullptr;
+ double now = EngineImpl::get_clock();
+ while (const auto* var = get_constraint()->get_variable(&elem)) {
+ Action* action = var->get_id();
+ if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED) {
+ action->set_finish_time(now);
+ action->set_state(Action::State::FAILED);
+ }
+ }
}
}
return lmm_policy;
}
+void DiskImpl::set_read_bandwidth(double value)
+{
+ read_bw_.peak = value;
+ if (constraint_read_)
+ get_model()->get_maxmin_system()->update_constraint_bound(constraint_read_, read_bw_.peak * read_bw_.scale);
+}
+
+void DiskImpl::set_write_bandwidth(double value)
+{
+ write_bw_.peak = value;
+ if (constraint_write_) {
+ get_model()->get_maxmin_system()->update_constraint_bound(constraint_write_, write_bw_.peak* write_bw_.scale);
+ }
+}
+
+void DiskImpl::set_readwrite_bandwidth(double value)
+{
+ readwrite_bw_ = value;
+ if (get_constraint()) {
+ get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), readwrite_bw_);
+ }
+}
+
void DiskImpl::set_sharing_policy(s4u::Disk::Operation op, s4u::Disk::SharingPolicy policy,
const s4u::NonLinearResourceCb& cb)
{
on_state_change(*this, previous_state, new_state);
}
}
-} // namespace resource
-} // namespace kernel
-} // namespace simgrid
+
+void DiskAction::update_remains_lazy(double /*now*/)
+{
+ THROW_IMPOSSIBLE;
+}
+} // namespace simgrid::kernel::resource