Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Initialize CPU model for VMs in init_HL13
[simgrid.git] / src / surf / disk_s19.cpp
index 3d114cc..8e910ff 100644 (file)
@@ -5,8 +5,10 @@
 
 #include "disk_s19.hpp"
 #include "simgrid/kernel/routing/NetPoint.hpp"
+#include "simgrid/kernel/routing/NetZoneImpl.hpp"
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
+#include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/lmm/maxmin.hpp"
 #include "src/surf/xml/platf.hpp"
 #include "surf/surf.hpp"
@@ -19,21 +21,19 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_disk);
 
 void surf_disk_model_init_default()
 {
-  surf_disk_model = new simgrid::kernel::resource::DiskS19Model();
+  auto disk_model = std::make_shared<simgrid::kernel::resource::DiskS19Model>();
+  simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::DISK, disk_model,
+                                                         true);
+  simgrid::s4u::Engine::get_instance()->get_netzone_root()->get_impl()->set_disk_model(disk_model);
 }
 
 namespace simgrid {
 namespace kernel {
 namespace resource {
 
-DiskS19Model::DiskS19Model()
+DiskImpl* DiskS19Model::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
 {
-  all_existing_models.push_back(this);
-}
-
-DiskImpl* DiskS19Model::create_disk()
-{
-  return new DiskS19();
+  return (new DiskS19(name, read_bandwidth, write_bandwidth))->set_model(this);
 }
 
 double DiskS19Model::next_occurring_event(double now)
@@ -59,7 +59,6 @@ void DiskS19Model::update_actions_state(double /*now*/, double delta)
 /************
  * Resource *
  ************/
-
 DiskAction* DiskS19::io_start(sg_size_t size, s4u::Io::OpType type)
 {
   return new DiskS19Action(get_model(), static_cast<double>(size), not is_on(), this, type);