/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include <stdio.h>
#include <stdlib.h>
#include "simgrid/msg.h"
#include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_semaphore_example,
- "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_semaphore_example, "Messages specific for this msg example");
msg_sem_t sem;
static int peer(int argc, char* argv[]){
-
int i = 0;
-
while(i < argc) {
double wait_time = xbt_str_parse_double(argv[i++],"Invalid wait time: %s");
MSG_process_sleep(wait_time);
return 0;
}
-int main(int argc, char* argv[]) {
-
+int main(int argc, char* argv[])
+{
MSG_init(&argc, argv);
MSG_create_environment(argv[1]);
-
+
xbt_dynar_t hosts = MSG_hosts_as_dynar();
msg_host_t h = xbt_dynar_get_as(hosts,0,msg_host_t);
bobTimes[nbBob++] = xbt_strdup("0");
bobTimes[nbBob++] = xbt_strdup("5");
bobTimes[nbBob++] = NULL;
-
- MSG_process_create_with_arguments(xbt_strdup("Alice"), peer, NULL,
- h, 8, aliceTimes);
- MSG_process_create_with_arguments(xbt_strdup("Bob"), peer, NULL,
- h, 8, bobTimes);
+ MSG_process_create_with_arguments(xbt_strdup("Alice"), peer, NULL, h, 8, aliceTimes);
+ MSG_process_create_with_arguments(xbt_strdup("Bob"), peer, NULL, h, 8, bobTimes);
msg_error_t res = MSG_main();
- printf("Finished\n");
+ XBT_INFO("Finished\n");
return (res != MSG_OK);
}
--- /dev/null
+#! ./tesh
+
+p Testing synchronization with semaphores
+
+! output sort 19
+$ $SG_TEST_EXENV semaphores/synchro ${srcdir:=.}/../platforms/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:Alice@Fafard) Trying to acquire 1
+> [ 0.000000] (1:Alice@Fafard) Acquired 1
+> [ 0.900000] (2:Bob@Fafard) Trying to acquire 1
+> [ 1.000000] (1:Alice@Fafard) Releasing 2
+> [ 1.000000] (2:Bob@Fafard) Acquired 1
+> [ 1.000000] (1:Alice@Fafard) Released 2
+> [ 2.000000] (2:Bob@Fafard) Releasing 2
+> [ 2.000000] (2:Bob@Fafard) Released 2
+> [ 3.000000] (2:Bob@Fafard) Trying to acquire 3
+> [ 3.000000] (2:Bob@Fafard) Acquired 3
+> [ 4.000000] (1:Alice@Fafard) Trying to acquire 3
+> [ 5.000000] (2:Bob@Fafard) Releasing 4
+> [ 5.000000] (1:Alice@Fafard) Acquired 3
+> [ 5.000000] (2:Bob@Fafard) Released 4
+> [ 7.000000] (2:Bob@Fafard) Trying to acquire 5
+> [ 10.000000] (1:Alice@Fafard) Releasing 4
+> [ 10.000000] (2:Bob@Fafard) Acquired 5
+> [ 10.000000] (1:Alice@Fafard) Released 4
+> [ 10.000000] (2:Bob@Fafard) Releasing 6
+> [ 10.000000] (2:Bob@Fafard) Released 6
+> [ 10.000000] (2:Bob@Fafard) Trying to acquire 7
+> [ 10.000000] (2:Bob@Fafard) Acquired 7
+> [ 11.000000] (1:Alice@Fafard) Trying to acquire 5
+> [ 15.000000] (2:Bob@Fafard) Releasing 8
+> [ 15.000000] (1:Alice@Fafard) Acquired 5
+> [ 15.000000] (2:Bob@Fafard) Released 8
+> [ 17.000000] (1:Alice@Fafard) Releasing 6
+> [ 17.000000] (1:Alice@Fafard) Released 6
+> [ 22.000000] (1:Alice@Fafard) Trying to acquire 7
+> [ 22.000000] (1:Alice@Fafard) Acquired 7
+> [ 22.000000] (1:Alice@Fafard) Releasing 8
+> [ 22.000000] (1:Alice@Fafard) Released 8
+> [ 65.000000] (2:Bob@Fafard) Done
+> [ 72.000000] (1:Alice@Fafard) Done
+> [ 72.000000] (0:maestro@) Finished
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
ADD_TESH_FACTORIES(msg-ptask "thread;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/parallel_task/parallel_task.tesh)
ADD_TESH_FACTORIES(msg-priority "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/priority/priority.tesh)
ADD_TESH_FACTORIES(msg-properties "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/properties/msg_prop.tesh)
+ ADD_TESH_FACTORIES(msg-semaphores "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/semaphores/synchro.tesh)
ADD_TESH_FACTORIES(msg-icomms "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg/icomms --cd ${CMAKE_BINARY_DIR}/examples/msg/icomms ${CMAKE_HOME_DIRECTORY}/examples/msg/icomms/peer.tesh)
ADD_TESH_FACTORIES(msg-actions "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/actions --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/actions actions.tesh)
ADD_TESH_FACTORIES(msg-chord-no-crosstraffic "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/chord --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/chord chord.tesh)