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, task2;
20 MSG_task_receive(&task1, "mymailbox");
21 val1 = (long) MSG_task_get_data(task1);
22 MSG_task_destroy(task1);
24 XBT_INFO("Received %lu", val1);
26 MSG_task_receive(&task2, "mymailbox");
27 val2 = (long) MSG_task_get_data(task2);
28 MSG_task_destroy(task2);
30 XBT_INFO("Received %lu", val2);
32 MC_assert_stateful(min(val1, val2) == 1);
34 MSG_task_receive(&task1, "mymailbox");
35 val1 = (long) MSG_task_get_data(task1);
36 MSG_task_destroy(task1);
37 XBT_INFO("Received %lu", val1);
39 MSG_task_receive(&task2, "mymailbox");
40 val2 = (long) MSG_task_get_data(task2);
41 MSG_task_destroy(task2);
42 XBT_INFO("Received %lu", val2);
48 int client(int argc, char *argv[])
51 MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
53 MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
55 XBT_INFO("Send %d!", atoi(argv[1]));
56 MSG_task_send(task1, "mymailbox");
58 XBT_INFO("Send %d!", atoi(argv[1]));
59 MSG_task_send(task2, "mymailbox");
64 int main(int argc, char *argv[])
66 MSG_global_init(&argc, argv);
68 MSG_create_environment("platform.xml");
70 MSG_function_register("server", server);
72 MSG_function_register("client", client);
74 MSG_launch_application("deploy_bugged2.xml");