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 INFO1("Received %lu", val1);
38 int client(int argc,char *argv[])
42 m_task_t task1 = MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
44 mbox = bprintf("mymailbox%s", argv[1]);
46 INFO1("Send %d!", atoi(argv[1]));
47 comm = MSG_task_isend(task1,mbox);
48 MSG_comm_wait(comm, -1);
55 int main(int argc,char*argv[])
57 MSG_global_init(&argc,argv);
59 MSG_create_environment("platform.xml");
61 MSG_function_register("server", server);
63 MSG_function_register("client", client);
65 MSG_launch_application("deploy_bugged3.xml");