Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
factoring and cleanups for msg/tracing
[simgrid.git] / examples / msg / tracing / simple.c
1 /* Copyright (c) 2010, 2012-2015. 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 "simgrid/msg.h"
9 #include "xbt/sysdep.h"         /* calloc, printf */
10
11 /** @addtogroup MSG_examples
12  * 
13  * @section MSG_ex_tracing Tracing and vizualisation 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:yes
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, "Messages specific for this msg example");
25
26 static int simple_func(int argc, char *argv[])
27 {
28   msg_task_t task = MSG_task_create("task", 100, 0, NULL);
29   MSG_task_execute (task);
30   MSG_task_destroy (task);
31   return 0;
32 }
33
34 int main(int argc, char *argv[])
35 {
36   MSG_init(&argc, argv);
37   if (argc < 3) {
38     printf("Usage: %s platform_file deployment_file\n", argv[0]);
39     exit(1);
40   }
41
42   MSG_create_environment(argv[1]);
43
44   MSG_function_register("master", simple_func);
45   MSG_function_register("slave", simple_func);
46   MSG_launch_application(argv[2]);
47
48   MSG_main();
49   return 0;
50 }