Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update all our XML files + next XML version will be 4.1, not 5
[simgrid.git] / examples / msg / mc / bugged1.c
1 /* Copyright (c) 2010-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
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 /******************************************************************************/
11
12 #include <simgrid/msg.h>
13 #include <simgrid/modelchecker.h>
14
15 #define N 3
16
17 XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
18
19 static int server(int argc, char *argv[])
20 {
21   msg_task_t task = NULL;
22   int count = 0;
23   while (count < N) {
24     if (task) {
25       MSG_task_destroy(task);
26       task = NULL;
27     }
28     MSG_task_receive(&task, "mymailbox");
29     count++;
30   }
31   int value_got = xbt_str_parse_int(MSG_task_get_name(task), "Task names must be integers, not '%s'");
32   MC_assert(value_got == 3);
33
34   XBT_INFO("OK");
35   return 0;
36 }
37
38 static int client(int argc, char *argv[])
39 {
40   msg_task_t task =  MSG_task_create(argv[1], 0 /*comp cost */ , 10000 /*comm size */ , NULL /*arbitrary data */ );
41
42   MSG_task_send(task, "mymailbox");
43
44   XBT_INFO("Sent!");
45   return 0;
46 }
47
48 int main(int argc, char *argv[])
49 {
50   MSG_init(&argc, argv);
51
52   MSG_create_environment("platform.xml");
53
54   MSG_function_register("server", server);
55   MSG_function_register("client", client);
56   MSG_launch_application("deploy_bugged1.xml");
57
58   MSG_main();
59   return 0;
60 }