X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4d1ec2c6d07f420ab949ec906dd6ca207819dd88..dcbef682c82dc36f62828f331ba4adc39d0324ea:/examples/msg/cloud/bound.c diff --git a/examples/msg/cloud/bound.c b/examples/msg/cloud/bound.c index 854f1af8b0..e721f3ac98 100644 --- a/examples/msg/cloud/bound.c +++ b/examples/msg/cloud/bound.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2007-2013. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2014. The SimGrid Team. + * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -273,6 +274,7 @@ static int master_main(int argc, char *argv[]) { xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar(); msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t); + msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t); { @@ -339,7 +341,46 @@ static int master_main(int argc, char *argv[]) } - XBT_INFO("# 10. Change a bound dynamically."); + { + msg_host_t vm0 = MSG_vm_create_core(pm0, "VM0"); + + s_ws_params_t params; + memset(¶ms, 0, sizeof(params)); + params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes + MSG_host_set_params(vm0, ¶ms); + MSG_vm_start(vm0); + + const double cpu_speed = MSG_get_host_speed(pm0); + MSG_vm_start(vm0); + + XBT_INFO("# 10. Test migration"); + const double computation_amount = cpu_speed * 10; + + XBT_INFO("# 10. (a) Put a task on a VM without any bound."); + launch_worker(vm0, "worker0", computation_amount, 0, 0); + MSG_process_sleep(1000); + XBT_INFO(" "); + + XBT_INFO("# 10. (b) set 10%% bound to the VM, and then put a task on the VM."); + MSG_vm_set_bound(vm0, cpu_speed / 10); + launch_worker(vm0, "worker0", computation_amount, 0, 0); + MSG_process_sleep(1000); + XBT_INFO(" "); + + XBT_INFO("# 10. (c) migrate"); + MSG_vm_migrate(vm0, pm1); + XBT_INFO(" "); + + XBT_INFO("# 10. (d) Put a task again on the VM."); + launch_worker(vm0, "worker0", computation_amount, 0, 0); + MSG_process_sleep(1000); + XBT_INFO(" "); + + MSG_vm_destroy(vm0); + } + + + XBT_INFO("# 11. Change a bound dynamically."); test_dynamic_change(); return 0;