Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add the test of allReduce replay
[simgrid.git] / examples / msg / mc / bugged1.c
1 /* Copyright (c) 2012. 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
8 /******************** Non-deterministic message ordering  *********************/
9 /* Server assumes a fixed order in the reception of messages from its clients */
10 /* which is incorrect because the message ordering is non-deterministic       */
11 /******************************************************************************/
12
13 #include <msg/msg.h>
14 #include <simgrid/modelchecker.h>
15
16 #define N 3
17
18 XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
19
20 int server(int argc, char *argv[]);
21 int client(int argc, char *argv[]);
22
23 int server(int argc, char *argv[])
24 {
25   msg_task_t task = NULL;
26   int count = 0;
27   while (count < N) {
28     if (task) {
29       MSG_task_destroy(task);
30       task = NULL;
31     }
32     MSG_task_receive(&task, "mymailbox");
33     count++;
34   }
35   MC_assert(atoi(MSG_task_get_name(task)) == 3);
36
37   XBT_INFO("OK");
38   return 0;
39 }
40
41 int client(int argc, char *argv[])
42 {
43
44   msg_task_t task =
45       MSG_task_create(argv[1], 0 /*comp cost */ , 10000 /*comm size */ ,
46                       NULL /*arbitrary data */ );
47
48   MSG_task_send(task, "mymailbox");
49
50   XBT_INFO("Sent!");
51   return 0;
52 }
53
54 int main(int argc, char *argv[])
55 {
56
57   MSG_init(&argc, argv);
58
59   MSG_create_environment("platform.xml");
60
61   MSG_function_register("server", server);
62
63   MSG_function_register("client", client);
64
65   MSG_launch_application("deploy_bugged1.xml");
66
67   MSG_main();
68
69   return 0;
70
71 }