Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
06e7bea47dc8de382425c4c0f4cca50505b7bdcf
[simgrid.git] / examples / msg / chainsend / chainsend.c
1 /* Copyright (c) 2007-2010, 2012. The SimGrid Team.
2  * Copyright (c) 2012. Maximiliano Geier.
3  * All rights reserved.                                                     */
4
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. */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10
11 #include "msg/msg.h"            /* Yeah! If you want to use msg, you need to include msg/msg.h */
12 #include "xbt/sysdep.h"         /* calloc */
13
14 /* Create a log channel to have nice outputs. */
15 #include "xbt/log.h"
16 #include "xbt/asserts.h"
17
18 #include "iterator.h"
19 #include "messages.h"
20 #include "broadcaster.h"
21 #include "peer.h"
22
23 /** @addtogroup MSG_examples
24  * 
25  *  - <b>chainsend/chainsend.c: Chainsend implementation</b>.
26  */
27
28
29 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chainsend,
30                              "Messages specific for chainsend");
31
32 /*
33  Data structures
34  */
35
36 /* Initialization stuff */
37 msg_error_t test_all(const char *platform_file,
38                      const char *application_file);
39
40
41 /** Test function */
42 msg_error_t test_all(const char *platform_file,
43                      const char *application_file)
44 {
45
46   msg_error_t res = MSG_OK;
47
48
49
50   XBT_DEBUG("test_all");
51
52   /*  Simulation setting */
53   MSG_create_environment(platform_file);
54
55   /* Trace categories */
56   TRACE_category_with_color("host0", "0 0 1");
57   TRACE_category_with_color("host1", "0 1 0");
58   TRACE_category_with_color("host2", "0 1 1");
59   TRACE_category_with_color("host3", "1 0 0");
60   TRACE_category_with_color("host4", "1 0 1");
61   TRACE_category_with_color("host5", "0 0 0");
62   TRACE_category_with_color("host6", "1 1 0");
63   TRACE_category_with_color("host7", "1 1 1");
64   TRACE_category_with_color("host8", "0 1 0");
65
66   /*   Application deployment */
67   MSG_function_register("broadcaster", broadcaster);
68   MSG_function_register("peer", peer);
69
70   MSG_launch_application(application_file);
71
72   res = MSG_main();
73
74   return res;
75 }                               /* end_of_test_all */
76
77
78 /** Main function */
79 int main(int argc, char *argv[])
80 {
81   msg_error_t res = MSG_OK;
82
83 #ifdef _MSC_VER
84   unsigned int prev_exponent_format =
85       _set_output_format(_TWO_DIGIT_EXPONENT);
86 #endif
87
88   MSG_init(&argc, argv);
89
90   /*if (argc <= 3) {
91     XBT_CRITICAL("Usage: %s platform_file deployment_file <model>\n",
92               argv[0]);
93     XBT_CRITICAL
94         ("example: %s msg_platform.xml msg_deployment.xml KCCFLN05_Vegas\n",
95          argv[0]);
96     exit(1);
97   }*/
98
99   /* Options for the workstation/model:
100
101      KCCFLN05              => for maxmin
102      KCCFLN05_proportional => for proportional (Vegas)
103      KCCFLN05_Vegas        => for TCP Vegas
104      KCCFLN05_Reno         => for TCP Reno
105    */
106   //MSG_config("workstation/model", argv[3]);
107
108   res = test_all(argv[1], argv[2]);
109
110   XBT_INFO("Total simulation time: %e", MSG_get_clock());
111
112 #ifdef _MSC_VER
113   _set_output_format(prev_exponent_format);
114 #endif
115
116   if (res == MSG_OK)
117     return 0;
118   else
119     return 1;
120 }                               /* end_of_main */