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 /******************************************************************************/
7 #include <mc/modelchecker.h>
10 XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
12 int server(int argc, char *argv[]);
13 int client(int argc, char *argv[]);
15 int server(int argc, char *argv[])
17 m_task_t task1 = NULL;
18 m_task_t task2 = NULL;
21 MSG_task_receive(&task1, "mymailbox");
22 val1 = (long) MSG_task_get_data(task1);
23 MSG_task_destroy(task1);
25 XBT_INFO("Received %lu", val1);
27 MSG_task_receive(&task2, "mymailbox");
28 val2 = (long) MSG_task_get_data(task2);
29 MSG_task_destroy(task2);
31 XBT_INFO("Received %lu", val2);
33 MC_assert(min(val1, val2) == 1);
35 MSG_task_receive(&task1, "mymailbox");
36 val1 = (long) MSG_task_get_data(task1);
37 MSG_task_destroy(task1);
38 XBT_INFO("Received %lu", val1);
40 MSG_task_receive(&task2, "mymailbox");
41 val2 = (long) MSG_task_get_data(task2);
42 MSG_task_destroy(task2);
43 XBT_INFO("Received %lu", val2);
49 int client(int argc, char *argv[])
52 MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
54 MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
56 XBT_INFO("Send %d!", atoi(argv[1]));
57 MSG_task_send(task1, "mymailbox");
59 XBT_INFO("Send %d!", atoi(argv[1]));
60 MSG_task_send(task2, "mymailbox");
65 int main(int argc, char *argv[])
67 MSG_global_init(&argc, argv);
69 MSG_create_environment("platform.xml");
71 MSG_function_register("server", server);
73 MSG_function_register("client", client);
75 MSG_launch_application("deploy_bugged2.xml");