1 /* Copyright (c) 2008-2018. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "simgrid/s4u.hpp"
8 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u test");
12 simgrid::s4u::Storage* storage = simgrid::s4u::Storage::by_name("Disk1");
13 int id = simgrid::s4u::this_actor::get_pid();
14 XBT_INFO("process %d is writing!", id);
15 storage->write(3000000);
16 XBT_INFO("process %d goes to sleep for %d seconds", id, id);
17 simgrid::s4u::this_actor::sleep_for(id);
18 XBT_INFO("process %d is writing again!", id);
19 storage->write(3000000);
20 XBT_INFO("process %d goes to sleep for %d seconds", id, 6 - id);
21 simgrid::s4u::this_actor::sleep_for(6 - id);
22 XBT_INFO("process %d is reading!", id);
23 storage->read(3000000);
24 XBT_INFO("process %d goes to sleep for %d seconds", id, id);
25 simgrid::s4u::this_actor::sleep_for(id);
26 XBT_INFO("process %d is reading again!", id);
27 storage->read(3000000);
30 int main(int argc, char** argv)
32 simgrid::s4u::Engine e(&argc, argv);
33 e.load_platform(argv[1]);
35 for (int i = 0; i < 5; i++)
36 simgrid::s4u::Actor::create("host", simgrid::s4u::Host::by_name("bob"), host);
39 XBT_INFO("Simulation time %g", e.get_clock());