Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
desperate attempt :
[simgrid.git] / examples / msg / chainsend / chainsend.c
1 /* Copyright (c) 2007-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 <stdlib.h>
9
10 #include "simgrid/msg.h"        /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
11 #include "xbt/sysdep.h"         /* calloc */
12
13 /* Create a log channel to have nice outputs. */
14 #include "xbt/log.h"
15 #include "xbt/asserts.h"
16
17 #include "iterator.h"
18 #include "messages.h"
19 #include "broadcaster.h"
20 #include "peer.h"
21
22 /** @addtogroup MSG_examples
23  * 
24  *  - <b>chainsend/chainsend.c: Chainsend implementation</b>.
25  */
26
27
28 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chainsend,
29                              "Messages specific for chainsend");
30
31 /*
32  Data structures
33  */
34
35 /* Initialization stuff */
36 msg_error_t test_all(const char *platform_file,
37                      const char *application_file);
38
39
40 /** Test function */
41 msg_error_t test_all(const char *platform_file,
42                      const char *application_file)
43 {
44
45   msg_error_t res = MSG_OK;
46
47   XBT_DEBUG("test_all");
48
49   /*  Simulation setting */
50   MSG_create_environment(platform_file);
51
52   /* Trace categories */
53   TRACE_category_with_color("host0", "0 0 1");
54   TRACE_category_with_color("host1", "0 1 0");
55   TRACE_category_with_color("host2", "0 1 1");
56   TRACE_category_with_color("host3", "1 0 0");
57   TRACE_category_with_color("host4", "1 0 1");
58   TRACE_category_with_color("host5", "0 0 0");
59   TRACE_category_with_color("host6", "1 1 0");
60   TRACE_category_with_color("host7", "1 1 1");
61   TRACE_category_with_color("host8", "0 1 0");
62
63   /*   Application deployment */
64   MSG_function_register("broadcaster", broadcaster);
65   MSG_function_register("peer", peer);
66
67   MSG_launch_application(application_file);
68
69   res = MSG_main();
70
71   return res;
72 }                               /* end_of_test_all */
73
74
75 /** Main function */
76 int main(int argc, char *argv[])
77 {
78   msg_error_t res = MSG_OK;
79
80 #ifdef _MSC_VER
81   unsigned int prev_exponent_format =
82       _set_output_format(_TWO_DIGIT_EXPONENT);
83 #endif
84
85   MSG_init(&argc, argv);
86
87   res = test_all(argv[1], argv[2]);
88
89   XBT_INFO("Total simulation time: %e", MSG_get_clock());
90
91 #ifdef _MSC_VER
92   _set_output_format(prev_exponent_format);
93 #endif
94
95   return res != MSG_OK;
96 }