X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9a26840d5c76893c3b805b17c62079aeded90fc9..eb71d4f20b115188c0521f064f9427e01a916f72:/src/kernel/resource/DiskImpl.hpp diff --git a/src/kernel/resource/DiskImpl.hpp b/src/kernel/resource/DiskImpl.hpp new file mode 100644 index 0000000000..8645dd0f07 --- /dev/null +++ b/src/kernel/resource/DiskImpl.hpp @@ -0,0 +1,113 @@ +/* Copyright (c) 2019. 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 "simgrid/kernel/resource/Action.hpp" +#include "simgrid/kernel/resource/Model.hpp" +#include "simgrid/kernel/resource/Resource.hpp" +#include "simgrid/s4u/Io.hpp" +#include "src/surf/PropertyHolder.hpp" +#include "src/surf/surf_interface.hpp" + +#include + +#ifndef DISK_INTERFACE_HPP_ +#define DISK_INTERFACE_HPP_ + +/********* + * Model * + *********/ + +XBT_PUBLIC_DATA simgrid::kernel::resource::DiskModel* surf_disk_model; + +namespace simgrid { +namespace kernel { +namespace resource { +/*********** + * Classes * + ***********/ + +class DiskAction; + +/********* + * Model * + *********/ +class DiskModel : public kernel::resource::Model { +public: + DiskModel(); + DiskModel(const DiskModel&) = delete; + DiskModel& operator=(const DiskModel&) = delete; + ~DiskModel(); + + virtual DiskImpl* createDisk(const std::string& id, double read_bw, double write_bw) = 0; +}; + +/************ + * Resource * + ************/ +class DiskImpl : public Resource, public surf::PropertyHolder { + bool currently_destroying_ = false; + +public: + DiskImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double read_bw, double bwrite_bw); + DiskImpl(const DiskImpl&) = delete; + DiskImpl& operator=(const DiskImpl&) = delete; + + ~DiskImpl() override; + + /** @brief Public interface */ + // FIXME s4u::Storage piface_; + + /** @brief Check if the Storage is used (if an action currently uses its resources) */ + bool is_used() override; + + void apply_event(profile::Event* event, double value) override; + + void turn_on() override; + void turn_off() override; + + void destroy(); // Must be called instead of the destructor + virtual DiskAction* io_start(sg_size_t size, s4u::Io::OpType type) = 0; + virtual DiskAction* read(sg_size_t size) = 0; + virtual DiskAction* write(sg_size_t size) = 0; + + lmm::Constraint* constraint_write_; /* Constraint for maximum write bandwidth*/ + lmm::Constraint* constraint_read_; /* Constraint for maximum write bandwidth*/ +}; + +/********** + * Action * + **********/ + +class DiskAction : public Action { +public: + static xbt::signal on_state_change; + + DiskAction(Model* model, double cost, bool failed, DiskImpl* disk, s4u::Io::OpType type) + : Action(model, cost, failed), type_(type), disk_(disk){}; + + /** + * @brief diskAction constructor + * + * @param model The StorageModel associated to this DiskAction + * @param cost The cost of this DiskAction in bytes + * @param failed [description] + * @param var The lmm variable associated to this DiskAction if it is part of a LMM component + * @param storage The Storage associated to this DiskAction + * @param type [description] + */ + DiskAction(kernel::resource::Model* model, double cost, bool failed, kernel::lmm::Variable* var, DiskImpl* disk, + s4u::Io::OpType type) + : Action(model, cost, failed, var), type_(type), disk_(disk){}; + + void set_state(simgrid::kernel::resource::Action::State state) override; + + s4u::Io::OpType type_; + DiskImpl* disk_; +}; + +} // namespace resource +} // namespace kernel +} // namespace simgrid +#endif /* DISK_INTERFACE_HPP_ */