3 /* Copyright (c) 2009 The SimGrid team. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #include "msg/msg.h" /* core library */
9 #include "xbt/sysdep.h" /* calloc */
11 /* Create a log channel to have nice outputs. */
13 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
14 "Messages specific for this msg example");
16 /** The guy we will move from host to host. It move alone and then is moved by policeman back */
17 static int emigrant(int argc, char *argv[])
21 ("I'll look for a new job on another machine where the grass is greener.");
22 MSG_process_change_host(MSG_get_host_by_name("Boivin"));
23 INFO0("Yeah, found something to do");
24 task = MSG_task_create("job", 98095000, 0, NULL);
25 MSG_task_execute(task);
26 MSG_task_destroy(task);
27 INFO0("Moving back home after work");
28 MSG_process_change_host(MSG_get_host_by_name("Jacquelin"));
29 INFO0("Uh, nothing to do here. Stopping now");
31 } /* end_of_emigrant */
33 /* This function would move the emigrant back home, if it were possible to do so in the MSG API.
36 static int policeman(int argc, char *argv[])
38 INFO0("No function in the API to move the emigrant back, so do nothing.");
40 } /* end_of_policeman */
44 int main(int argc, char *argv[])
46 MSG_error_t res = MSG_OK;
48 /* Argument checking */
49 MSG_global_init(&argc, argv);
51 CRITICAL1("Usage: %s platform_file deployment_file\n", argv[0]);
52 CRITICAL1("example: %s msg_platform.xml msg_deployment_suspend.xml\n",
57 /* Simulation setting */
58 MSG_create_environment(argv[1]);
60 /* Application deployment */
61 MSG_function_register("emigrant", emigrant);
62 MSG_launch_application(argv[2]);
64 /* Run the simulation */
66 INFO1("Simulation time %g", MSG_get_clock());