1 /* Copyright (c) 2010-2023. 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 code tests that we can change the stack-size between the actors creation. */
8 #include "simgrid/actor.h"
9 #include "simgrid/engine.h"
10 #include "simgrid/host.h"
12 #include "xbt/config.h"
15 XBT_LOG_NEW_DEFAULT_CATEGORY(actor_stacksize, "Messages specific for this example");
17 static void actor(int argc, char* argv[])
22 int main(int argc, char* argv[])
24 simgrid_init(&argc, argv);
25 simgrid_load_platform(argv[1]);
27 // If you don't specify anything, you get the default size (8Mb) or the one passed on the command line
28 sg_actor_create("actor", sg_host_by_name("Tremblay"), actor, 0, NULL);
30 // You can use sg_cfg_set_int(key, value) to pass a size that will be parsed. That value will be used for any
32 sg_cfg_set_int("contexts/stack-size", 16384);
33 sg_actor_create("actor", sg_host_by_name("Tremblay"), actor, 0, NULL);
34 sg_actor_create("actor", sg_host_by_name("Tremblay"), actor, 0, NULL);
36 sg_cfg_set_int("contexts/stack-size", 32 * 1024);
37 sg_actor_create("actor", sg_host_by_name("Tremblay"), actor, 0, NULL);
38 sg_actor_create("actor", sg_host_by_name("Tremblay"), actor, 0, NULL);
40 // Or you can use set_stacksize() before starting the actor to modify only this one
41 sg_actor_t a = sg_actor_init("actor", sg_host_by_name("Tremblay"));
42 sg_actor_set_stacksize(a, 64 * 1024);
43 sg_actor_start(a, actor, 0, NULL);
45 sg_actor_create("actor", sg_host_by_name("Tremblay"), actor, 0, NULL);
48 XBT_INFO("Simulation time %g", simgrid_get_clock());