1 /* Copyright (c) 2012. 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. */
9 int master(int argc, char *argv[]);
11 //dump function to create and execute a task
12 static void create_and_execute_task (void)
14 m_task_t task = MSG_task_create("task", 1000000, 0, NULL);
15 MSG_task_execute (task);
16 MSG_task_destroy (task);
19 int master(int argc, char *argv[])
23 //Set initial values for the link user variables
25 //This example uses source and destination where
26 //source and destination are the name of hosts in
29 //The functions will set/change the value of the variable
30 //for all links in the route between source and destination.
32 //Set the Link_Capacity variable
33 TRACE_link_srcdst_variable_set("Tremblay", "Bourassa", "Link_Capacity", 12.34);
34 TRACE_link_srcdst_variable_set("Fafard", "Ginette", "Link_Capacity", 56.78);
36 //Set the Link_Utilization variable
37 TRACE_link_srcdst_variable_set("Tremblay", "Bourassa", "Link_Utilization", 1.2);
38 TRACE_link_srcdst_variable_set("Fafard", "Ginette", "Link_Utilization", 3.4);
40 //run the simulation, update my variables accordingly
41 for (i = 0; i < 10; i++) {
42 create_and_execute_task ();
44 //Add to link user variables
45 TRACE_link_srcdst_variable_add ("Tremblay", "Bourassa", "Link_Utilization", 5.6);
46 TRACE_link_srcdst_variable_add ("Fafard", "Ginette", "Link_Utilization", 7.8);
49 for (i = 0; i < 10; i++) {
50 create_and_execute_task ();
52 //Subtract from link user variables
53 TRACE_link_srcdst_variable_sub ("Tremblay", "Bourassa", "Link_Utilization", 3.4);
54 TRACE_link_srcdst_variable_sub ("Fafard", "Ginette", "Link_Utilization", 5.6);
61 int main(int argc, char *argv[])
63 MSG_global_init(&argc, argv);
65 printf("Usage: %s platform_file deployment_file\n", argv[0]);
69 char *platform_file = argv[1];
70 char *deployment_file = argv[2];
71 MSG_create_environment(platform_file);
73 //declaring link user variables (one without, another with a RGB color)
74 TRACE_link_variable_declare("Link_Capacity");
75 TRACE_link_variable_declare_with_color ("Link_Utilization", "0.9 0.1 0.1");
77 //register "master" and "slave" functions and launch deployment
78 MSG_function_register("master", master);
79 MSG_function_register("slave", master);
80 MSG_launch_application(deployment_file);