Logo AND Algorithmique Numérique Distribuée

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