Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics.
[simgrid.git] / teshsuite / s4u / io-stream / io-stream.cpp
index d6b69af..96154a2 100644 (file)
@@ -61,13 +61,11 @@ static void streamer(size_t size)
 
   XBT_INFO("Start two 10-second background traffic between Bob and Alice");
   sg4::CommPtr bt1 = sg4::Comm::sendto_async(bob, alice, 2e7);
-  sg4::CommPtr bt2 = sg4::Comm::sendto_async(bob, alice, 2e7);
   XBT_INFO("[Bob -> Alice] Streaming (Transfer bottleneck)");
   clock = sg4::Engine::get_clock();
   sg4::Io::streamto(bob, bob_disk, alice, alice_disk, size);
   XBT_INFO("    Total : %.6f seconds", sg4::Engine::get_clock() - clock);
   bt1->wait();
-  bt2->wait();
 
   XBT_INFO("[Bob -> Alice] Streaming \"from disk to memory\" (no write)");
   clock = sg4::Engine::get_clock();
@@ -83,7 +81,19 @@ static void streamer(size_t size)
   clock = sg4::Engine::get_clock();
   sg4::Io::streamto(bob, bob_disk, bob, bob_disk, size);
   XBT_INFO("    Total : %.6f seconds", sg4::Engine::get_clock() - clock);
+}
+
+static void background_send() {
+  sg4::this_actor::sleep_for(23.000150);
+  sg4::Mailbox::by_name("mbox")->put(new double(1), 2e7);
+}
 
+static void background_recv() {
+  double* res;
+  sg4::CommPtr comm = sg4::Mailbox::by_name("mbox")->get_async<double>(&res);
+  sg4::this_actor::sleep_for(33.1);
+  comm->wait();
+  delete res;
 }
 
 int main(int argc, char** argv)
@@ -98,12 +108,14 @@ int main(int argc, char** argv)
   sg4::LinkInRoute link(zone->create_link("link", "2MBps")->set_latency("50us")->seal());
   zone->add_route(bob->get_netpoint(), alice->get_netpoint(), nullptr, nullptr, {link}, true);
 
-  bob->create_disk("bob_disk", 1e6, 5e5);
+  bob->create_disk("bob_disk", "1MBps", "500kBps");
   alice->create_disk("alice_disk", 4e6, 4e6);
 
   zone->seal();
 
   sg4::Actor::create("streamer", bob, streamer, 4e6);
+  sg4::Actor::create("background send", bob, background_send);
+  sg4::Actor::create("background recv", alice, background_recv);
 
   e.run();