1 /* Copyright (c) 2012-2015. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #include <simgrid/msg.h>
9 /** @addtogroup MSG_examples
11 * - <b>tracing/link_user_variables.c</b>: This program demonstrates how to trace user variables associated to the
12 * links of the platform file. You need to provide the name of the link to update the value of the variable associated
13 * to that link. You might want to run this program with the following parameters:
15 * --cfg=tracing/platform:yes
16 * (See \ref tracing_tracing_options for details)
19 //dump function to create and execute a task
20 static void create_and_execute_task (void)
22 msg_task_t task = MSG_task_create("task", 1000000, 0, NULL);
23 MSG_task_execute (task);
24 MSG_task_destroy (task);
27 static int master(int argc, char *argv[])
29 //set initial values for the link user variables this example only shows for links identified by "6" and "3" in the
32 //Set the Link_Capacity variable
33 TRACE_link_variable_set("6", "Link_Capacity", 12.34);
34 TRACE_link_variable_set("3", "Link_Capacity", 56.78);
36 //Set the Link_Utilization variable
37 TRACE_link_variable_set("3", "Link_Utilization", 1.2);
38 TRACE_link_variable_set("6", "Link_Utilization", 3.4);
40 //run the simulation, update my variables accordingly
41 for (int i = 0; i < 10; i++) {
42 create_and_execute_task ();
44 //Add to link user variables
45 TRACE_link_variable_add ("3", "Link_Utilization", 5.6);
46 TRACE_link_variable_add ("6", "Link_Utilization", 7.8);
49 for (int i = 0; i < 10; i++) {
50 create_and_execute_task ();
52 //Subtract from link user variables
53 TRACE_link_variable_sub ("3", "Link_Utilization", 3.4);
54 TRACE_link_variable_sub ("6", "Link_Utilization", 5.6);
60 int main(int argc, char *argv[])
62 MSG_init(&argc, argv);
64 printf("Usage: %s platform_file deployment_file\n", argv[0]);
68 MSG_create_environment(argv[1]);
70 //declaring link user variables (one without, another with a RGB color)
71 TRACE_link_variable_declare("Link_Capacity");
72 TRACE_link_variable_declare_with_color ("Link_Utilization", "0.9 0.1 0.1");
74 //register "master" and "slave" functions and launch deployment
75 MSG_function_register("master", master);
76 MSG_function_register("slave", master);
77 MSG_launch_application(argv[2]);