Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Deprecate MSG_clean
[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 where each process creates, executes and
16  *   destroy a task. You might want to run this program with the following parameters:
17  *   --cfg=tracing/uncategorized:1
18  *   (See \ref tracing_tracing_options for details)
19  */
20
21 /* Create a log channel to have nice outputs. */
22 #include "xbt/log.h"
23 #include "xbt/asserts.h"
24 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
25                              "Messages specific for this msg example");
26
27 int simple_func(int argc, char *argv[]);
28
29 /** Emitter function  */
30 int simple_func(int argc, char *argv[])
31 {
32   msg_task_t task = MSG_task_create("task", 100, 0, NULL);
33   MSG_task_execute (task);
34   MSG_task_destroy (task);
35   return 0;
36 }
37
38 /** Main function */
39 int main(int argc, char *argv[])
40 {
41   MSG_init(&argc, argv);
42   if (argc < 3) {
43     printf("Usage: %s platform_file deployment_file\n", argv[0]);
44     exit(1);
45   }
46
47   char *platform_file = argv[1];
48   char *deployment_file = argv[2];
49   MSG_create_environment(platform_file);
50
51   MSG_function_register("master", simple_func);
52   MSG_function_register("slave", simple_func);
53   MSG_launch_application(deployment_file);
54
55   MSG_main();
56   return 0;
57 }