1 /* Copyright (c) 2008-2010, 2012-2015, 2017. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/s4u.hpp"
10 #define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
12 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u test");
17 int id = simgrid::s4u::this_actor::pid();
18 snprintf(name, 2048, "%s%i", FILENAME1, id);
19 simgrid::s4u::File* file = new simgrid::s4u::File(name, NULL);
20 XBT_INFO("process %d is writing!", id);
22 XBT_INFO("process %d goes to sleep for %d seconds", id, id);
23 simgrid::s4u::this_actor::sleep_for(id);
24 XBT_INFO("process %d is writing again!", id);
26 XBT_INFO("process %d goes to sleep for %d seconds", id, 6 - id);
27 simgrid::s4u::this_actor::sleep_for(6 - id);
28 XBT_INFO("process %d is reading!", id);
31 XBT_INFO("process %d goes to sleep for %d seconds", id, id);
32 simgrid::s4u::this_actor::sleep_for(id);
33 XBT_INFO("process %d is reading again!", id);
37 XBT_INFO("process %d => Size of %s: %llu", id, name, file->size());
42 int main(int argc, char** argv)
44 simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
45 e->loadPlatform(argv[1]);
47 for (int i = 0; i < 5; i++)
48 simgrid::s4u::Actor::createActor("host", simgrid::s4u::Host::by_name("bob"), host);
51 XBT_INFO("Simulation time %g", e->getClock());