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 #include "simgrid/actor.h"
7 #include "simgrid/engine.h"
8 #include "simgrid/host.h"
10 #include "xbt/asserts.h"
13 XBT_LOG_NEW_DEFAULT_CATEGORY(exec_basic, "Messages specific for this example");
15 static void executor(int argc, char* argv[])
17 /* sg_actor_execute() tells SimGrid to pause the calling actor
18 * until its host has computed the amount of flops passed as a parameter */
19 sg_actor_execute(98095);
22 /* This simple example does not do anything beyond that */
25 static void privileged(int argc, char* argv[])
27 /* sg_actor_execute_with_priority() specifies that this execution gets a larger share of the resource.
29 * Since the priority is 2, it computes twice as fast as a regular one.
31 * So instead of a half/half sharing between the two executions,
32 * we get a 1/3 vs 2/3 sharing. */
33 sg_actor_execute_with_priority(98095, 2);
36 /* Note that the timings printed when executing this example are a bit misleading,
37 * because the uneven sharing only last until the privileged actor ends.
38 * After this point, the unprivileged one gets 100% of the CPU and finishes
42 int main(int argc, char* argv[])
44 simgrid_init(&argc, argv);
45 xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s ../platforms/small_platform.xml\n", argv[0], argv[0]);
47 simgrid_load_platform(argv[1]);
49 sg_actor_create("executor", sg_host_by_name("Tremblay"), executor, 0, NULL);
50 sg_actor_create("privileged", sg_host_by_name("Tremblay"), privileged, 0, NULL);