Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a018c1a97aaf3582c722d5a8b54560ba729e9e7d
[simgrid.git] / examples / msg / mc / electric_fence.c
1 /* Copyright (c) 2013-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 /******************** Non-deterministic message ordering  *********************/
8 /* This example implements one process which receives messages from two other */
9 /* processes. There is no bug on it, it is just provided to test the soundness*/ 
10 /* of the state space reduction with DPOR, if the maximum depth (defined with */
11 /* --cfg=model-check/max_depth:) is reached.                                  */
12 /******************************************************************************/
13
14 #include <simgrid/msg.h>
15 #include <simgrid/modelchecker.h>
16
17 #define N 2
18
19 XBT_LOG_NEW_DEFAULT_CATEGORY(electric_fence, "Example to check the soundness of DPOR");
20
21 int server(int argc, char *argv[]);
22 int client(int argc, char *argv[]);
23
24 int server(int argc, char *argv[])
25 {
26   msg_task_t task1 = NULL, task2 = NULL;
27   msg_comm_t comm_received1 = NULL, comm_received2 = NULL;
28
29   comm_received1 = MSG_task_irecv(&task1, "mymailbox");
30   comm_received2 = MSG_task_irecv(&task2, "mymailbox");
31
32   MSG_comm_wait(comm_received1, -1);
33   MSG_comm_wait(comm_received2, -1);
34
35   XBT_INFO("OK");
36   return 0;
37 }
38
39 int client(int argc, char *argv[])
40 {
41
42   msg_task_t task = MSG_task_create(argv[1], 0, 10000, NULL);
43
44   MSG_task_send(task, "mymailbox");
45   
46   XBT_INFO("Sent!");
47   return 0;
48 }
49
50 int main(int argc, char *argv[])
51 {
52
53   MSG_init(&argc, argv);
54
55   MSG_create_environment("platform.xml");
56
57   MSG_function_register("server", server);
58
59   MSG_function_register("client", client);
60
61   MSG_launch_application("deploy_electric_fence.xml");
62
63   MSG_main();
64
65   return 0;
66
67 }