-/* Copyright (c) 2013-2021. The SimGrid Team.
+/* Copyright (c) 2013-2023. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
{
int i = 0;
while (i < argc) {
- double wait_time = xbt_str_parse_double(argv[i], "Invalid wait time: %s");
+ double wait_time = xbt_str_parse_double(argv[i], "Invalid wait time");
i++;
sg_actor_sleep_for(wait_time);
- XBT_INFO("Trying to acquire %d (%sblocking)", i, sg_sem_would_block(sem) ? "" : "not ");
// cover the two cases: with and without timeout
if (i > 1) {
- while (sg_sem_acquire_timeout(sem, 3.0))
- XBT_INFO("Timeout.. Try again %d", i);
+ XBT_INFO("Trying for 1 sec to acquire #%d (that is %sfree)", i, sg_sem_would_block(sem) ? "not " : "");
+ while (sg_sem_acquire_timeout(sem, 1.)) {
+ XBT_INFO("Timeout.. Try #%d for another second.", i);
+ }
} else {
+ XBT_INFO("Acquire #%d (that is %sfree)", i, sg_sem_would_block(sem) ? "not " : "");
sg_sem_acquire(sem);
}
- XBT_INFO("Acquired %d", i);
+ XBT_INFO("Acquired #%d", i);
- wait_time = xbt_str_parse_double(argv[i], "Invalid wait time: %s");
+ wait_time = xbt_str_parse_double(argv[i], "Invalid wait time");
i++;
sg_actor_sleep_for(wait_time);
- XBT_INFO("Releasing %d", i);
+ XBT_INFO("Releasing #%d", i);
sg_sem_release(sem);
- XBT_INFO("Released %d", i);
+ XBT_INFO("Released #%d", i);
}
sg_actor_sleep_for(50);
XBT_INFO("Done");
const char* aliceTimes[] = {"0", "1", "3", "5", "1", "2", "5", "0"};
const char* bobTimes[] = {"0.9", "1", "1", "2", "2", "0", "0", "5"};
- sg_actor_create("Alice", h, peer, 8, (char**)aliceTimes);
- sg_actor_create("Bob", h, peer, 8, (char**)bobTimes);
+ sg_actor_create_("Alice", h, peer, 8, aliceTimes);
+ sg_actor_create_("Bob", h, peer, 8, bobTimes);
simgrid_run();
sg_sem_destroy(sem);