1 /* Copyright (c) 2009-2013. The SimGrid Team.
2 * All rights reserved. */
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. */
11 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Messages specific to this example");
14 static int send(int argc, char *argv[])
17 MSG_task_send(MSG_task_create("Blah", 0.0, 0.0, NULL), MSG_host_get_name(MSG_host_self()));
18 MSG_process_sleep(1.); /* FIXME: if the sender exits before the receiver calls get_sender(), bad thing happens */
23 static int receive(int argc, char *argv[])
25 XBT_INFO("Receiving");
26 msg_task_t task = NULL;
27 MSG_task_receive_with_timeout(&task, MSG_host_get_name(MSG_host_self()), DBL_MAX);
28 xbt_assert(MSG_task_get_sender(task), "No sender received");
29 XBT_INFO("Got a message sent by '%s'",
30 MSG_process_get_name(MSG_task_get_sender(task)));
31 MSG_task_destroy(task);
36 int main(int argc, char *argv[])
38 msg_error_t res = MSG_OK;
40 MSG_init(&argc, argv);
42 /* Application deployment */
43 MSG_function_register("send", &send);
44 MSG_function_register("receive", &receive);
46 MSG_create_environment(argv[1]);
47 MSG_launch_application(argv[2]);