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[])
15 msg_host_t jupiter = MSG_host_by_name("Jupiter");
16 XBT_INFO("Master waiting");
19 XBT_INFO("Turning off the slave host");
20 MSG_host_off(jupiter);
21 XBT_INFO("Master has finished");
24 xbt_die("Exception caught in the master");
30 static int slave(int argc, char *argv[])
34 XBT_INFO("Slave waiting");
35 // TODO, This should really be MSG_HOST_FAILURE
37 XBT_ERROR("Slave should be off already.");
41 XBT_ERROR("Exception caught in the slave");
47 int main(int argc, char *argv[])
51 MSG_init(&argc, argv);
52 xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
54 MSG_create_environment(argv[1]);
56 MSG_process_create("master", master, NULL, MSG_get_host_by_name("Tremblay"));
57 MSG_process_create("slave", slave, NULL, MSG_get_host_by_name("Jupiter"));
61 XBT_INFO("Simulation time %g", MSG_get_clock());