1 /**************** Shared buffer between asynchronous receives *****************/
2 /* Server process assumes that the data from the second communication comm2 */
3 /* will overwrite the one from the first communication, because of the order */
4 /* of the wait calls. This is not true because data copy can be triggered by */
5 /* a call to wait on the other end of the communication (client). */
6 /* NOTE that the communications use different mailboxes, but they share the */
7 /* same buffer for reception (task1). */
8 /******************************************************************************/
11 #include <mc/modelchecker.h>
13 XBT_LOG_NEW_DEFAULT_CATEGORY(bugged3, "this example");
15 int server(int argc, char *argv[]);
16 int client(int argc, char *argv[]);
18 int server(int argc, char *argv[])
22 msg_comm_t comm1, comm2;
24 comm1 = MSG_task_irecv(&task1, "mymailbox1");
25 comm2 = MSG_task_irecv(&task1, "mymailbox2");
26 MSG_comm_wait(comm1, -1);
27 MSG_comm_wait(comm2, -1);
29 val1 = (long) MSG_task_get_data(task1);
30 XBT_INFO("Received %lu", val1);
38 int client(int argc, char *argv[])
43 MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
45 mbox = bprintf("mymailbox%s", argv[1]);
47 XBT_INFO("Send %d!", atoi(argv[1]));
48 comm = MSG_task_isend(task1, mbox);
49 MSG_comm_wait(comm, -1);
56 int main(int argc, char *argv[])
58 MSG_global_init(&argc, argv);
60 MSG_create_environment("platform.xml");
62 MSG_function_register("server", server);
64 MSG_function_register("client", client);
66 MSG_launch_application("deploy_bugged3.xml");