Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further improve the MSG doc by documenting the examples
[simgrid.git] / examples / msg / tracing / simple.c
1 /* Copyright (c) 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include <stdio.h>
8 #include "msg/msg.h"
9 #include "xbt/sysdep.h"         /* calloc, printf */
10
11 /** @addtogroup MSG_examples
12  * 
13  * @section MSG_ex_tracing Tracing and vizualization features
14  * 
15  * - <b>tracing/simple.c</b> very simple program that creates, executes and destroy a task
16  */
17
18 /* Create a log channel to have nice outputs. */
19 #include "xbt/log.h"
20 #include "xbt/asserts.h"
21 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
22                              "Messages specific for this msg example");
23
24 int simple_func(int argc, char *argv[]);
25
26 /** Emitter function  */
27 int simple_func(int argc, char *argv[])
28 {
29   m_task_t task = MSG_task_create("task", 100, 0, NULL);
30   MSG_task_execute (task);
31   MSG_task_destroy (task);
32   return 0;
33 }
34
35 /** Main function */
36 int main(int argc, char *argv[])
37 {
38   MSG_global_init(&argc, argv);
39   if (argc < 3) {
40     printf("Usage: %s platform_file deployment_file\n", argv[0]);
41     exit(1);
42   }
43
44   char *platform_file = argv[1];
45   char *deployment_file = argv[2];
46   MSG_create_environment(platform_file);
47
48   MSG_function_register("master", simple_func);
49   MSG_function_register("slave", simple_func);
50   MSG_launch_application(deployment_file);
51
52   MSG_main();
53   MSG_clean();
54   return 0;
55 }