1 /* Copyright (c) 2010-2015. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 /******************** Non-deterministic message ordering *********************/
7 /* Server assumes a fixed order in the reception of messages from its clients */
8 /* which is incorrect because the message ordering is non-deterministic */
9 /******************************************************************************/
11 #include <simgrid/msg.h>
12 #include <simgrid/modelchecker.h>
15 XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
17 static int server(int argc, char *argv[])
19 msg_task_t task1 = NULL;
20 msg_task_t task2 = NULL;
22 MSG_task_receive(&task1, "mymailbox");
23 long val1 = xbt_str_parse_int(MSG_task_get_name(task1), "Task name is not a numerical ID: %s");
24 MSG_task_destroy(task1);
26 XBT_INFO("Received %lu", val1);
28 MSG_task_receive(&task2, "mymailbox");
29 long val2 = xbt_str_parse_int(MSG_task_get_name(task2), "Task name is not a numerical ID: %s");
30 MSG_task_destroy(task2);
32 XBT_INFO("Received %lu", val2);
34 MC_assert(MIN(val1, val2) == 1);
36 MSG_task_receive(&task1, "mymailbox");
37 val1 = xbt_str_parse_int(MSG_task_get_name(task1), "Task name is not a numerical ID: %s");
38 MSG_task_destroy(task1);
39 XBT_INFO("Received %lu", val1);
41 MSG_task_receive(&task2, "mymailbox");
42 val2 = xbt_str_parse_int(MSG_task_get_name(task2), "Task name is not a numerical ID: %s");
43 MSG_task_destroy(task2);
44 XBT_INFO("Received %lu", val2);
50 static int client(int argc, char *argv[])
52 msg_task_t task1 = MSG_task_create(argv[1], 0, 10000, NULL);
53 msg_task_t task2 = MSG_task_create(argv[1], 0, 10000, NULL);
55 XBT_INFO("Send %s", argv[1]);
56 MSG_task_send(task1, "mymailbox");
58 XBT_INFO("Send %s", argv[1]);
59 MSG_task_send(task2, "mymailbox");
64 int main(int argc, char *argv[])
66 MSG_init(&argc, argv);
68 MSG_create_environment("platform.xml");
70 MSG_function_register("server", server);
71 MSG_function_register("client", client);
72 MSG_launch_application("deploy_bugged2.xml");