1 /* Copyright (c) 2010-2015. 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. */
7 #include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
9 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
11 static int master(int argc, char *argv[])
13 msg_host_t jupiter = MSG_host_by_name("Jupiter");
14 XBT_INFO("Master waiting");
17 XBT_INFO("Turning off the slave host");
18 MSG_host_off(jupiter);
19 XBT_INFO("Master has finished");
24 static int slave(int argc, char *argv[])
26 XBT_INFO("Slave waiting");
27 // TODO, This should really be MSG_HOST_FAILURE
29 XBT_ERROR("Slave should be off already.");
33 int main(int argc, char *argv[])
37 MSG_init(&argc, argv);
38 xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
40 MSG_create_environment(argv[1]);
42 MSG_process_create("master", master, NULL, MSG_get_host_by_name("Tremblay"));
43 MSG_process_create("slave", slave, NULL, MSG_get_host_by_name("Jupiter"));
47 XBT_INFO("Simulation time %g", MSG_get_clock());