1 /* Copyright (c) 2008-2017. 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"
9 #define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
11 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u test");
16 int id = simgrid::s4u::this_actor::getPid();
17 snprintf(name, 2048, "%s%i", FILENAME1, id);
18 simgrid::s4u::File* file = new simgrid::s4u::File(name, NULL);
19 XBT_INFO("process %d is writing!", id);
21 XBT_INFO("process %d goes to sleep for %d seconds", id, id);
22 simgrid::s4u::this_actor::sleep_for(id);
23 XBT_INFO("process %d is writing again!", id);
25 XBT_INFO("process %d goes to sleep for %d seconds", id, 6 - id);
26 simgrid::s4u::this_actor::sleep_for(6 - id);
27 XBT_INFO("process %d is reading!", id);
30 XBT_INFO("process %d goes to sleep for %d seconds", id, id);
31 simgrid::s4u::this_actor::sleep_for(id);
32 XBT_INFO("process %d is reading again!", id);
36 XBT_INFO("process %d => Size of %s: %llu", id, name, file->size());
41 int main(int argc, char** argv)
43 simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
44 e->loadPlatform(argv[1]);
46 for (int i = 0; i < 5; i++)
47 simgrid::s4u::Actor::createActor("host", simgrid::s4u::Host::by_name("bob"), host);
50 XBT_INFO("Simulation time %g", e->getClock());