Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / examples / cpp / io-disk-raw / s4u-io-disk-raw.cpp
index 4b36beb..925291f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2022. 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,6 +11,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(disk_test, "Messages specific for this simulation")
 
 static void host()
 {
+  /* -Add an extra disk in a programmatic way */
+  simgrid::s4u::Host::current()->create_disk("Disk3", /*read bandwidth*/ 9.6e7, /*write bandwidth*/6.4e7)->seal();
+
   /* - Display information on the disks mounted by the current host */
   XBT_INFO("*** Storage info on %s ***", simgrid::s4u::Host::current()->get_cname());
 
@@ -19,7 +22,7 @@ static void host()
 
   /* - For each disk mounted on host, display disk name and mount point */
   for (auto const& disk : disk_list)
-    XBT_INFO("Disk name: %s (read: %.0f B/s -- write: %.0f B/s ", disk->get_cname(), disk->get_read_bandwidth(),
+    XBT_INFO("Disk name: %s (read: %.0f B/s -- write: %.0f B/s", disk->get_cname(), disk->get_read_bandwidth(),
              disk->get_write_bandwidth());
 
   /* - Write 400,000 bytes on Disk1 */
@@ -31,6 +34,11 @@ static void host()
   sg_size_t read = disk->read(200000);
   XBT_INFO("Read %llu bytes on '%s'", read, disk->get_cname());
 
+  /* - Write 800,000 bytes on Disk3 */
+  const simgrid::s4u::Disk* disk3 = disk_list.back();
+  sg_size_t write_on_disk3        = disk3->write(800000);
+  XBT_INFO("Wrote %llu bytes on '%s'", write_on_disk3, disk3->get_cname());
+
   /* - Attach some user data to disk1 */
   XBT_INFO("*** Get/set data for storage element: Disk1 ***");
 
@@ -56,7 +64,7 @@ int main(int argc, char** argv)
       XBT_INFO("  %s -> %s", kv.first.c_str(), kv.second.c_str());
   }
 
-  simgrid::s4u::Actor::create("", simgrid::s4u::Host::by_name("bob"), host);
+  simgrid::s4u::Actor::create("", e.host_by_name("bob"), host);
 
   e.run();
   XBT_INFO("Simulated time: %g", simgrid::s4u::Engine::get_clock());