1 /* Copyright (c) 2007-2010, 2013-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. */
9 #include "simgrid/msg.h"
10 #include "xbt/sysdep.h" /* calloc */
11 #include "simgrid/plugins.h"
13 /* Create a log channel to have nice outputs. */
15 #include "xbt/asserts.h"
17 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
18 "Messages specific for this msg example");
20 static msg_host_t host1 = NULL;
21 static msg_host_t host2 = NULL;
22 static msg_vm_t vm1 = NULL;
24 int dvfs(int argc, char *argv[]);
26 static int worker_func() {
27 //MSG_process_on_exit(shutdown_vm, NULL);
29 msg_task_t task1 = MSG_task_create("t1", 300E6, 0, NULL);
30 MSG_task_execute (task1);
31 MSG_task_destroy(task1);
32 XBT_INFO("Worker fun done");
36 int dvfs(int argc, char *argv[])
38 host1 = MSG_host_by_name("MyHost1");
39 host2 = MSG_host_by_name("MyHost2");
42 XBT_INFO("Creating and starting a VM");
43 vm1 = MSG_vm_create(host1,
45 4, /* number of cpus */
49 1024 * 20, /* disk size */
50 10, /* mig netspeed */
54 // on Host1 create two tasks, one inside a VM the other one directly on the host
56 MSG_process_create("p11", worker_func, NULL, vm1);
57 MSG_process_create("p12", worker_func, NULL, host1);
58 //XBT_INFO("Task on Host started");
61 // on Host2, create two tasks directly on the host: Energy of host 1 and host 2 should be the same.
62 MSG_process_create("p21", worker_func, NULL, host2);
63 MSG_process_create("p22", worker_func, NULL, host2);
73 int main(int argc, char *argv[])
75 msg_error_t res = MSG_OK;
76 sg_energy_plugin_init();
77 MSG_init(&argc, argv);
80 XBT_CRITICAL("Usage: %s platform_file deployment_file\n",
83 ("example: %s msg_platform.xml msg_deployment.xml\n",
88 MSG_create_environment(argv[1]);
90 /* Application deployment */
91 MSG_function_register("dvfs_test", dvfs);
93 MSG_launch_application(argv[2]);
97 XBT_INFO("Total simulation time: %.2f", MSG_get_clock());