1 /* Copyright (c) 2010. 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 #include "xbt/sysdep.h" /* calloc, printf */
11 /* Create a log channel to have nice outputs. */
13 #include "xbt/asserts.h"
14 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
16 int master(int argc, char *argv[]);
18 int master(int argc, char *argv[])
20 char *hostname = MSG_host_self()->name;
23 //the hostname has an empty HDD with a capacity of 100000 (bytes)
24 TRACE_host_variable_set(hostname, "HDD_capacity", 100000);
25 TRACE_host_variable_set(hostname, "HDD_utilization", 0);
27 for (i = 0; i < 10; i++) {
28 //create and execute a task just to make the simulated time advance
29 m_task_t task = MSG_task_create("task", 10000, 0, NULL);
30 MSG_task_execute (task);
31 MSG_task_destroy (task);
33 //ADD: after the execution of this task, the HDD utilization increases by 100 (bytes)
34 TRACE_host_variable_add(hostname, "HDD_utilization", 100);
37 for (i = 0; i < 10; i++) {
38 //create and execute a task just to make the simulated time advance
39 m_task_t task = MSG_task_create("task", 10000, 0, NULL);
40 MSG_task_execute (task);
41 MSG_task_destroy (task);
43 //SUB: after the execution of this task, the HDD utilization decreases by 100 (bytes)
44 TRACE_host_variable_sub(hostname, "HDD_utilization", 100);
50 int main(int argc, char *argv[])
52 MSG_global_init(&argc, argv);
54 printf("Usage: %s platform_file deployment_file\n", argv[0]);
58 char *platform_file = argv[1];
59 char *deployment_file = argv[2];
60 MSG_create_environment(platform_file);
62 //declaring user variables
63 TRACE_host_variable_declare("HDD_capacity");
64 TRACE_host_variable_declare("HDD_utilization");
66 //register functions and launch deployment
67 MSG_function_register("master", master);
68 MSG_function_register("slave", master);
69 MSG_launch_application(deployment_file);