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. */
9 #include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */
10 #include "xbt.h" /* calloc, printf */
12 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
15 static void send(xbt_dynar_t action) {
16 INFO1("Send: %s",xbt_str_join(action," "));
18 static void recv(xbt_dynar_t action) {
19 INFO1("Recv: %s",xbt_str_join(action," "));
21 static void sleep(xbt_dynar_t action) {
22 INFO1("Recv: %s",xbt_str_join(action," "));
24 static void compute(xbt_dynar_t action) {
25 INFO1("compute: %s",xbt_str_join(action," "));
29 int main(int argc, char *argv[]){
30 MSG_error_t res = MSG_OK;
32 /* Check the given arguments */
33 MSG_global_init(&argc,argv);
35 printf ("Usage: %s platform_file deployment_file action_files\n",argv[0]);
36 printf ("example: %s msg_platform.xml msg_deployment.xml actions\n",argv[0]);
40 /* Simulation setting */
41 MSG_create_environment(argv[1]);
43 /* No need to register functions as in classical MSG programs: the actions get started anyway */
44 MSG_launch_application(argv[2]);
46 /* Action registration */
47 MSG_action_register("send", send);
48 MSG_action_register("recv", recv);
49 MSG_action_register("sleep", sleep);
50 MSG_action_register("compute", sleep);
52 /* Actually do the simulation using MSG_action_trace_run */
53 res = MSG_action_trace_run(argv[3]);
55 INFO1("Simulation time %g",MSG_get_clock());