1 /* Copyright (c) 2009, 2010. 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_put(MSG_task_create("Blah", 0.0, 0.0, NULL), MSG_host_self(),
19 MSG_process_sleep(1.); /* FIXME: if the sender exits before the receiver calls get_sender(), bad thing happens */
24 static int receive(int argc, char *argv[])
26 XBT_INFO("Receiving");
28 MSG_task_get_with_timeout(&task, 0, DBL_MAX);
29 xbt_assert(MSG_task_get_sender(task), "No sender received");
30 XBT_INFO("Got a message sent by '%s'",
31 MSG_process_get_name(MSG_task_get_sender(task)));
36 int main(int argc, char *argv[])
38 MSG_error_t res = MSG_OK;
40 MSG_global_init(&argc, argv);
41 MSG_set_channel_number(100);
43 /* Application deployment */
44 MSG_function_register("send", &send);
45 MSG_function_register("receive", &receive);
47 MSG_create_environment(argv[1]);
48 MSG_launch_application(argv[1]);