XBT_INFO(" Total : %.6f seconds", sg4::Engine::get_clock());
XBT_INFO("[Bob -> Alice] Store and Forward (100 blocks)");
- sg4::IoPtr read = bob_disk->read_async(size/100.0);
- sg4::CommPtr transfer = sg4::Comm::sendto_async(bob, alice, size/100.0);
- sg4::IoPtr write = alice_disk->write_async(size/100.);
+ sg4::IoPtr read = bob_disk->read_async(size / 100);
+ sg4::CommPtr transfer = sg4::Comm::sendto_async(bob, alice, size / 100);
+ sg4::IoPtr write = alice_disk->write_async(size / 100);
clock = sg4::Engine::get_clock();
for (int i = 0; i < 99; i++){
read->wait();
- read = bob_disk->read_async(size/100.0);
+ read = bob_disk->read_async(size / 100);
transfer->wait();
- transfer = sg4::Comm::sendto_async(bob, alice, size/100.0);
+ transfer = sg4::Comm::sendto_async(bob, alice, size / 100);
write->wait();
- write = alice_disk->write_async(size/100.);
+ write = alice_disk->write_async(size / 100);
}
read->wait();
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();
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)
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();