1 /* Copyright (c) 2013-2020. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/actor.h"
8 #include "simgrid/engine.h"
9 #include "simgrid/host.h"
10 #include "simgrid/semaphore.h"
15 XBT_LOG_NEW_DEFAULT_CATEGORY(semaphores, "Messages specific for this example");
19 static void peer(int argc, char* argv[])
23 double wait_time = xbt_str_parse_double(argv[i], "Invalid wait time: %s");
25 sg_actor_sleep_for(wait_time);
26 XBT_INFO("Trying to acquire %d", i);
28 XBT_INFO("Acquired %d", i);
30 wait_time = xbt_str_parse_double(argv[i], "Invalid wait time: %s");
32 sg_actor_sleep_for(wait_time);
33 XBT_INFO("Releasing %d", i);
35 XBT_INFO("Released %d", i);
37 sg_actor_sleep_for(50);
41 int main(int argc, char* argv[])
43 simgrid_init(&argc, argv);
44 simgrid_load_platform(argv[1]);
46 sg_host_t h = sg_host_by_name("Fafard");
49 const char* aliceTimes[] = {"0", "1", "3", "5", "1", "2", "5", "0"};
50 const char* bobTimes[] = {"0.9", "1", "1", "2", "2", "0", "0", "5"};
52 sg_actor_create("Alice", h, peer, 8, aliceTimes);
53 sg_actor_create("Bob", h, peer, 8, bobTimes);
57 XBT_INFO("Finished\n");