Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
regenerate test data for 64 bits
[simgrid.git] / teshsuite / msg / get_sender.c
1 #include <stdio.h>
2 #include "msg/msg.h"
3 #include <float.h>
4
5 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Messages specific to this example");
6
7
8 static int send(int argc, char *argv[]){
9   INFO0("Sending");
10   MSG_task_put(MSG_task_create("Blah", 0.0, 0.0, NULL),
11                MSG_host_self(), 0);
12   MSG_process_sleep(1.); /* FIXME: if the sender exits before the receiver calls get_sender(), bad thing happens */
13   INFO0("Exiting");
14   return 0;
15 }
16
17 static int receive(int argc, char *argv[]) {
18   INFO0("Receiving");
19   m_task_t task = NULL;
20   MSG_task_get_with_timeout(&task, 0, DBL_MAX);
21   xbt_assert0(MSG_task_get_sender(task), "No sender received");
22   INFO1("Got a message sent by '%s'", MSG_process_get_name(MSG_task_get_sender(task)));
23   return 0;
24 }
25
26 /** Main function */
27 int main(int argc, char *argv[]) {
28   MSG_error_t res = MSG_OK;
29
30   MSG_global_init(&argc,argv);
31   MSG_set_channel_number(100);
32
33   /*   Application deployment */
34   MSG_function_register("send", &send);
35   MSG_function_register("receive", &receive);
36
37   MSG_create_environment(argv[1]);
38   MSG_launch_application(argv[1]);
39   res = MSG_main();
40   MSG_clean();
41   if(res==MSG_OK) return 0;
42   else return 1;
43 }
44