Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move actor-stacksize from teshsuite to examples now that it's of some interest to...
[simgrid.git] / examples / s4u / actor-stacksize / s4u-actor-stacksize.cpp
1 /* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 /* This code tests that we can change the stack-size between the actors creation. */
7
8 #include "simgrid/s4u.hpp"
9
10 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
11
12 static void actor()
13 {
14   XBT_INFO("Hello");
15 }
16
17 int main(int argc, char* argv[])
18 {
19   simgrid::s4u::Engine e(&argc, argv);
20   e.load_platform(argv[1]);
21
22   // If you don't specify anything, you get the default size (8Mb) or the one passed on the command line
23   simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
24
25   // You can use set_config(string) to pass a size that will be parsed. That value will be used for any subsequent
26   // actors
27   e.set_config("contexts/stack-size:16384");
28   simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
29   simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
30
31   // You can use set_config(key, value) for the same effect.
32   e.set_config("contexts/stack-size", 32 * 1024);
33   simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
34   simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
35
36   // Or you can use set_stacksize() before starting the actor to modify only this one
37   simgrid::s4u::Actor::init("actor", simgrid::s4u::Host::by_name("Tremblay"))->set_stacksize(64 * 1024)->start(actor);
38   simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
39
40   e.run();
41   XBT_INFO("Simulation time %g", e.get_clock());
42
43   return 0;
44 }