1 /* Copyright (c) 2020. 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 is the MWE of https://framagit.org/simgrid/simgrid/-/issues/50
7 // The problem was occuring when suspending an actor that will be executed later in the same scheduling round
10 #include <simgrid/s4u.hpp>
15 XBT_LOG_NEW_DEFAULT_CATEGORY(mwe, "Minimum Working Example");
17 simgrid::s4u::ActorPtr receiver;
24 XBT_INFO("Starting.");
25 auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
26 int data = *(int*)mailbox->get();
27 XBT_INFO("Got %d at the end", data);
37 // If we sleep a bit here, this MWE works because the suspender is not trying to suspend someone executed later in
38 // the same scheduling round simgrid::s4u::this_actor::sleep_for(0.01);
40 XBT_INFO("Suspend the receiver...");
42 XBT_INFO("Resume the receiver...");
45 XBT_INFO("Sleeping 10 sec...");
46 simgrid::s4u::this_actor::sleep_for(10);
48 XBT_INFO("Sending a message to the receiver...");
49 auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
51 mailbox->put(&data, 4);
57 int main(int argc, char** argv)
60 simgrid::s4u::Engine* engine = new simgrid::s4u::Engine(&argc, argv);
62 engine->load_platform(argv[1]);
63 simgrid::s4u::Host* host = simgrid::s4u::Host::by_name("Tremblay");
65 simgrid::s4u::Actor::create("Suspender", host, Suspender());
66 receiver = simgrid::s4u::Actor::create("Receiver", host, Receiver());