From fe6718fb97372f0f8c09e33a41e0a55b10b4ba5f Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 26 Feb 2021 16:00:18 +0100 Subject: [PATCH] extend example with another disk --- examples/cpp/io-disk-raw/s4u-io-disk-raw.cpp | 13 +++++++++++++ examples/cpp/io-disk-raw/s4u-io-disk-raw.tesh | 10 ++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/examples/cpp/io-disk-raw/s4u-io-disk-raw.cpp b/examples/cpp/io-disk-raw/s4u-io-disk-raw.cpp index 4b36bebf2a..5498513510 100644 --- a/examples/cpp/io-disk-raw/s4u-io-disk-raw.cpp +++ b/examples/cpp/io-disk-raw/s4u-io-disk-raw.cpp @@ -11,6 +11,13 @@ 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() + ->set_name("Disk3") + ->set_read_bandwidth(9.6e7) + ->set_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()); @@ -31,6 +38,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 */ + 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,6 +68,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); e.run(); diff --git a/examples/cpp/io-disk-raw/s4u-io-disk-raw.tesh b/examples/cpp/io-disk-raw/s4u-io-disk-raw.tesh index 024aba7a00..2c8b5c3612 100644 --- a/examples/cpp/io-disk-raw/s4u-io-disk-raw.tesh +++ b/examples/cpp/io-disk-raw/s4u-io-disk-raw.tesh @@ -10,9 +10,11 @@ $ ${bindir}/s4u-io-disk-raw ${platfdir}/hosts_with_disks.xml "--log=root.fmt:[%1 > [ 0.000000] (1:@bob) *** Storage info on bob *** > [ 0.000000] (1:@bob) Disk name: Disk1 (read: 100000000 B/s -- write: 40000000 B/s > [ 0.000000] (1:@bob) Disk name: Disk2 (read: 200000000 B/s -- write: 80000000 B/s +> [ 0.000000] (1:@bob) Disk name: Disk3 (read: 96000000 B/s -- write: 64000000 B/s > [ 0.010000] (1:@bob) Wrote 400000 bytes on 'Disk1' > [ 0.012000] (1:@bob) Read 200000 bytes on 'Disk1' -> [ 0.012000] (1:@bob) *** Get/set data for storage element: Disk1 *** -> [ 0.012000] (1:@bob) Get storage data: 'No user data' -> [ 0.012000] (1:@bob) Set and get data: 'Some user data' -> [ 0.012000] (0:maestro@) Simulated time: 0.012 +> [ 0.024500] (1:@bob) Wrote 800000 bytes on 'Disk3' +> [ 0.024500] (1:@bob) *** Get/set data for storage element: Disk1 *** +> [ 0.024500] (1:@bob) Get storage data: 'No user data' +> [ 0.024500] (1:@bob) Set and get data: 'Some user data' +> [ 0.024500] (0:maestro@) Simulated time: 0.0245 -- 2.20.1