Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : new example for liveness properties
[simgrid.git] / examples / msg / mc / bugged1.c
1 /******************** Non-deterministic message ordering  *********************/
2 /* Server assumes a fixed order in the reception of messages from its clients */
3 /* which is incorrect because the message ordering is non-deterministic       */
4 /******************************************************************************/
5
6 #include <msg/msg.h>
7 #include <mc/modelchecker.h>
8 #define N 3
9
10 XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
11
12 int server(int argc, char *argv[]);
13 int client(int argc, char *argv[]);
14
15 int server(int argc, char *argv[])
16 {
17   m_task_t task = NULL;
18   int count = 0;
19   while (count < N) {
20     if (task) {
21       MSG_task_destroy(task);
22       task = NULL;
23     }
24     MSG_task_receive(&task, "mymailbox");
25     count++;
26   }
27   MC_assert(atoi(MSG_task_get_name(task)) == 3);
28
29   XBT_INFO("OK");
30   return 0;
31 }
32
33 int client(int argc, char *argv[])
34 {
35
36   m_task_t task =
37       MSG_task_create(argv[1], 0 /*comp cost */ , 10000 /*comm size */ ,
38                       NULL /*arbitrary data */ );
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
49   MSG_global_init(&argc, argv);
50
51   MSG_create_environment("platform.xml");
52
53   MSG_function_register("server", server);
54
55   MSG_function_register("client", client);
56
57   MSG_launch_application("deploy_bugged1.xml");
58
59   MSG_main();
60
61   MSG_clean();
62
63   return 0;
64
65 }