Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
factoring and cleanups for msg/tracing
[simgrid.git] / examples / msg / tracing / link_srcdst_user_variables.c
index aa1caf6..632f2d3 100644 (file)
@@ -8,21 +8,17 @@
 
 /** @addtogroup MSG_examples
  *
- * - <b>tracing/link_srcdst_user_variables.c</b>: This program demonstrates how to
- * trace user variables associated to the links of the platform file. Instead of
- * providing the name of the link to update one of its variable, this example shows
- * how to provide two hosts as parameter (source and destination, use their names as
- * defined in the platform file). The tracing mechanism will get the route between
- * these two hosts, if there is one defined in the platform file, and update the variable
- * of all the links of that route to the value provided.
+ * - <b>tracing/link_srcdst_user_variables.c</b>: This program demonstrates how to trace user variables associated to
+ * the links of the platform file. Instead of providing the name of the link to update one of its variable, this
+ * example shows how to provide two hosts as parameter (source and destination, use their names as defined in the
+ * platform file). The tracing mechanism will get the route between these two hosts, if there is one defined in the
+ * platform file, and update the variable of all the links of that route to the value provided.
  * You might want to run this program with the following parameters:
  * --cfg=tracing:yes
  * --cfg=tracing/platform:yes
  * (See \ref tracing_tracing_options for details)
  */
 
-int master(int argc, char *argv[]);
-
 //dump function to create and execute a task
 static void create_and_execute_task (void)
 {
@@ -31,18 +27,11 @@ static void create_and_execute_task (void)
   MSG_task_destroy (task);
 }
 
-int master(int argc, char *argv[])
+static int master(int argc, char *argv[])
 {
-  int i;
-
   //Set initial values for the link user variables
-  //
-  //This example uses source and destination where
-  //source and destination are the name of hosts in
-  //the platform file.
-  //
-  //The functions will set/change the value of the variable
-  //for all links in the route between source and destination.
+  //This example uses source and destination wheresource and destination are the name of hosts inthe platform file.
+  //The functions will set/change the value of the variablefor all links in the route between source and destination.
 
   //Set the Link_Capacity variable
   TRACE_link_srcdst_variable_set("Tremblay", "Bourassa", "Link_Capacity", 12.34);
@@ -53,7 +42,7 @@ int master(int argc, char *argv[])
   TRACE_link_srcdst_variable_set("Fafard", "Ginette", "Link_Utilization", 3.4);
 
   //run the simulation, update my variables accordingly
-  for (i = 0; i < 10; i++) {
+  for (int i = 0; i < 10; i++) {
     create_and_execute_task ();
 
     //Add to link user variables
@@ -61,7 +50,7 @@ int master(int argc, char *argv[])
     TRACE_link_srcdst_variable_add ("Fafard", "Ginette", "Link_Utilization", 7.8);
   }
 
-  for (i = 0; i < 10; i++) {
+  for (int i = 0; i < 10; i++) {
     create_and_execute_task ();
 
     //Subtract from link user variables
@@ -72,7 +61,6 @@ int master(int argc, char *argv[])
   return 0;
 }
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   MSG_init(&argc, argv);
@@ -81,9 +69,7 @@ int main(int argc, char *argv[])
     exit(1);
   }
 
-  char *platform_file = argv[1];
-  char *deployment_file = argv[2];
-  MSG_create_environment(platform_file);
+  MSG_create_environment(argv[1]);
 
   //declaring link user variables (one without, another with a RGB color)
   TRACE_link_variable_declare("Link_Capacity");
@@ -92,7 +78,7 @@ int main(int argc, char *argv[])
   //register "master" and "slave" functions and launch deployment
   MSG_function_register("master", master);
   MSG_function_register("slave", master);
-  MSG_launch_application(deployment_file);
+  MSG_launch_application(argv[2]);
 
   MSG_main();
   return 0;