Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: complete workaround in the error msg seen on modern systems
[simgrid.git] / examples / deprecated / msg / mc / bugged1.c
1 /* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
2
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. */
5
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 /******************************************************************************/
10
11 #include <simgrid/msg.h>
12 #include <simgrid/modelchecker.h>
13
14 #define N 3
15
16 XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
17
18 static int server(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
19 {
20   msg_task_t task = NULL;
21   int count = 0;
22   while (count < N) {
23     if (task) {
24       MSG_task_destroy(task);
25       task = NULL;
26     }
27     MSG_task_receive(&task, "mymailbox");
28     count++;
29   }
30   int value_got = xbt_str_parse_int(MSG_task_get_name(task), "Task names must be integers, not '%s'");
31   MC_assert(value_got == 3);
32
33   XBT_INFO("OK");
34   return 0;
35 }
36
37 static int client(int argc, char *argv[])
38 {
39   xbt_assert(argc == 2);
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 }