1 /* Copyright (c) 2012. The SimGrid Team.
2 * All rights reserved. */
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. */
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 /******************************************************************************/
14 #include <simgrid/modelchecker.h>
17 XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
19 int server(int argc, char *argv[]);
20 int client(int argc, char *argv[]);
22 int server(int argc, char *argv[])
24 msg_task_t task1 = NULL;
25 msg_task_t task2 = NULL;
28 MSG_task_receive(&task1, "mymailbox");
29 val1 = (long) MSG_task_get_data(task1);
30 MSG_task_destroy(task1);
32 XBT_INFO("Received %lu", val1);
34 MSG_task_receive(&task2, "mymailbox");
35 val2 = (long) MSG_task_get_data(task2);
36 MSG_task_destroy(task2);
38 XBT_INFO("Received %lu", val2);
40 MC_assert(min(val1, val2) == 1);
42 MSG_task_receive(&task1, "mymailbox");
43 val1 = (long) MSG_task_get_data(task1);
44 MSG_task_destroy(task1);
45 XBT_INFO("Received %lu", val1);
47 MSG_task_receive(&task2, "mymailbox");
48 val2 = (long) MSG_task_get_data(task2);
49 MSG_task_destroy(task2);
50 XBT_INFO("Received %lu", val2);
56 int client(int argc, char *argv[])
59 MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
61 MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
63 XBT_INFO("Send %d!", atoi(argv[1]));
64 MSG_task_send(task1, "mymailbox");
66 XBT_INFO("Send %d!", atoi(argv[1]));
67 MSG_task_send(task2, "mymailbox");
72 int main(int argc, char *argv[])
74 MSG_init(&argc, argv);
76 MSG_create_environment("platform.xml");
78 MSG_function_register("server", server);
80 MSG_function_register("client", client);
82 MSG_launch_application("deploy_bugged2.xml");