1 /* Copyright (c) 2014-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"
8 #include "simgrid/forward.h"
9 #include "simgrid/s4u/VirtualMachine.hpp"
10 #include "simgrid/s4u/forward.hpp"
12 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
14 simgrid::s4u::ExecPtr activity;
16 static void executor()
18 const char* actor_name = simgrid::s4u::this_actor::getCname();
19 const char* host_name = simgrid::s4u::Host::current()->getCname();
21 double clock_begin = simgrid::s4u::Engine::getClock();
22 XBT_INFO("%s:%s task 1 created %g", host_name, actor_name, clock_begin);
23 activity = simgrid::s4u::Actor::self()->exec_async(1e9);
25 double clock_end = simgrid::s4u::Engine::getClock();
27 XBT_INFO("%s:%s task 1 executed %g", host_name, actor_name, clock_end - clock_begin);
31 simgrid::s4u::this_actor::sleep_for(1);
33 clock_begin = simgrid::s4u::Engine::getClock();
34 XBT_INFO("%s:%s task 2 created %g", host_name, actor_name, clock_begin);
35 activity = simgrid::s4u::Actor::self()->exec_async(1e10);
37 clock_end = simgrid::s4u::Engine::getClock();
39 XBT_INFO("%s:%s task 2 executed %g", host_name, actor_name, clock_end - clock_begin);
44 simgrid::s4u::Actor::createActor("compute", simgrid::s4u::Host::by_name("Fafard"), executor);
46 while (simgrid::s4u::Engine::getClock() < 100) {
48 XBT_INFO("activity remaining duration: %g", activity->getRemains());
49 simgrid::s4u::this_actor::sleep_for(1);
52 simgrid::s4u::this_actor::sleep_for(10000);
55 int main(int argc, char* argv[])
57 simgrid::s4u::Engine e(&argc, argv);
58 e.loadPlatform(argv[1]); /* - Load the platform description */
60 simgrid::s4u::Actor::createActor("master_", simgrid::s4u::Host::by_name("Fafard"), monitor);
64 XBT_INFO("Simulation time %g", e.getClock());