1 /* Copyright (c) 2010-2021. 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 /* This source code simply loads the platform. This is only useful to play
7 * with the tracing module. See the tesh file to see how to generate the
11 #include "simgrid/instr.h"
12 #include "simgrid/s4u.hpp"
15 /* The guy we will move from host to host. It move alone and then is moved by policeman back */
16 static void emigrant()
18 auto mailbox = simgrid::s4u::Mailbox::by_name("master_mailbox");
20 simgrid::s4u::this_actor::sleep_for(2);
22 while (true) { // I am an eternal emigrant
23 auto destination = mailbox->get_unique<std::string>();
24 if (destination->empty())
25 break; // there is no destination, die
26 simgrid::s4u::this_actor::set_host(simgrid::s4u::Host::by_name(*destination));
27 simgrid::s4u::this_actor::sleep_for(2); // I am tired, have to sleep for 2 seconds
31 static void policeman()
33 // I am the master of emigrant process,
34 // I tell it where it must emigrate to.
35 auto destinations = {"Tremblay", "Jupiter", "Fafard", "Ginette", "Bourassa", "Fafard", "Tremblay", "Ginette", ""};
36 auto mailbox = simgrid::s4u::Mailbox::by_name("master_mailbox");
38 for (auto const& destination : destinations) {
39 mailbox->put_init(new std::string(destination), 0)->set_tracing_category("migration_order")->wait();
43 int main(int argc, char* argv[])
45 simgrid::s4u::Engine e(&argc, argv);
46 xbt_assert(argc > 1, "Usage: %s platform_file\n \tExample: %s small_platform.xml\n", argv[0], argv[0]);
48 e.load_platform(argv[1]);
50 TRACE_category("migration_order");
52 simgrid::s4u::Actor::create("emigrant", simgrid::s4u::Host::by_name("Fafard"), emigrant);
53 simgrid::s4u::Actor::create("policeman", simgrid::s4u::Host::by_name("Tremblay"), policeman);