X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/237fd22b56db7d1c67360c37559ce3aab16a002d..ebec9c6104a6bbe60b7bf4586baeaf0b88f53505:/src/kernel/resource/DiskImpl.cpp diff --git a/src/kernel/resource/DiskImpl.cpp b/src/kernel/resource/DiskImpl.cpp index fe2e269513..20c23ac077 100644 --- a/src/kernel/resource/DiskImpl.cpp +++ b/src/kernel/resource/DiskImpl.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2019-2021. 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. */ @@ -11,22 +11,10 @@ #include "src/kernel/resource/profile/Profile.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_disk, ker_resource, "Disk resources, that fuel I/O activities"); - -namespace simgrid { -namespace kernel { -namespace resource { +namespace simgrid::kernel::resource { xbt::signal DiskAction::on_state_change; -/********* - * Model * - *********/ - -DiskModel::DiskModel(const std::string& name) : Model(name) -{ - set_maxmin_system(new lmm::System(true /* selective update */)); -} - /************ * Resource * ************/ @@ -65,26 +53,25 @@ DiskImpl* DiskImpl::set_write_constraint(lmm::Constraint* constraint_write) void DiskImpl::destroy() { s4u::Disk::on_destruction(piface_); + piface_.on_this_destruction(piface_); delete this; } -bool DiskImpl::is_used() const -{ - return get_model()->get_maxmin_system()->constraint_used(get_constraint()); -} - void DiskImpl::turn_on() { 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_); + cancel_actions(); } } @@ -134,6 +121,29 @@ constexpr kernel::lmm::Constraint::SharingPolicy to_maxmin_policy(s4u::Disk::Sha 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) { @@ -177,6 +187,9 @@ void DiskAction::set_state(Action::State new_state) 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