1 /* Copyright (c) 2010-2015. 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. */
7 /******************** Non-deterministic message ordering *********************/
8 /* Server assumes a fixed order in the reception of messages from its clients */
9 /* which is incorrect because the message ordering is non-deterministic */
10 /******************************************************************************/
12 #include <simgrid/msg.h>
13 #include <simgrid/modelchecker.h>
16 XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
18 int server(int argc, char *argv[]);
19 int client(int argc, char *argv[]);
21 int server(int argc, char *argv[])
23 msg_task_t task1 = NULL;
24 msg_task_t task2 = NULL;
27 MSG_task_receive(&task1, "mymailbox");
28 val1 = xbt_str_parse_int(MSG_task_get_name(task1), "Task name is not a numerical ID: %s");
29 MSG_task_destroy(task1);
31 XBT_INFO("Received %lu", val1);
33 MSG_task_receive(&task2, "mymailbox");
34 val2 = xbt_str_parse_int(MSG_task_get_name(task2), "Task name is not a numerical ID: %s");
35 MSG_task_destroy(task2);
37 XBT_INFO("Received %lu", val2);
39 MC_assert(min(val1, val2) == 1);
41 MSG_task_receive(&task1, "mymailbox");
42 val1 = xbt_str_parse_int(MSG_task_get_name(task1), "Task name is not a numerical ID: %s");
43 MSG_task_destroy(task1);
44 XBT_INFO("Received %lu", val1);
46 MSG_task_receive(&task2, "mymailbox");
47 val2 = xbt_str_parse_int(MSG_task_get_name(task2), "Task name is not a numerical ID: %s");
48 MSG_task_destroy(task2);
49 XBT_INFO("Received %lu", val2);
55 int client(int argc, char *argv[])
57 msg_task_t task1 = MSG_task_create(argv[1], 0, 10000, NULL);
58 msg_task_t task2 = MSG_task_create(argv[1], 0, 10000, NULL);
60 XBT_INFO("Send %s", argv[1]);
61 MSG_task_send(task1, "mymailbox");
63 XBT_INFO("Send %s", argv[1]);
64 MSG_task_send(task2, "mymailbox");
69 int main(int argc, char *argv[])
71 MSG_init(&argc, argv);
73 MSG_create_environment("platform.xml");
75 MSG_function_register("server", server);
76 MSG_function_register("client", client);
77 MSG_launch_application("deploy_bugged2.xml");