1 /* Copyright (c) 2008-2022. 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");
10 namespace sg4 = simgrid::s4u;
14 const sg4::Disk* disk = sg4::this_actor::get_host()->get_disks().front(); // Disk1
15 aid_t id = sg4::this_actor::get_pid();
16 XBT_INFO("actor %ld is writing!", id);
18 XBT_INFO("actor %ld goes to sleep for %ld seconds", id, id);
19 sg4::this_actor::sleep_for(static_cast<double>(id));
20 XBT_INFO("actor %ld is writing again!", id);
22 XBT_INFO("actor %ld goes to sleep for %ld seconds", id, 6 - id);
23 sg4::this_actor::sleep_for(static_cast<double>(6 - id));
24 XBT_INFO("actor %ld is reading!", id);
26 XBT_INFO("actor %ld goes to sleep for %ld seconds", id, id);
27 sg4::this_actor::sleep_for(static_cast<double>(id));
28 XBT_INFO("actor %ld is reading again!", id);
32 int main(int argc, char** argv)
34 sg4::Engine e(&argc, argv);
35 e.load_platform(argv[1]);
37 for (int i = 0; i < 5; i++)
38 sg4::Actor::create("host", e.host_by_name("bob"), host);
41 XBT_INFO("Simulation time %g", sg4::Engine::get_clock());