A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use xxx_is_empty().
[simgrid.git]
/
examples
/
msg
/
cloud-masterworker
/
cloud-masterworker.c
diff --git
a/examples/msg/cloud-masterworker/cloud-masterworker.c
b/examples/msg/cloud-masterworker/cloud-masterworker.c
index
ab01626
..
93b2ef3
100644
(file)
--- a/
examples/msg/cloud-masterworker/cloud-masterworker.c
+++ b/
examples/msg/cloud-masterworker/cloud-masterworker.c
@@
-1,10
+1,12
@@
-/* Copyright (c) 2007-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2018. 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. */
#include "simgrid/msg.h"
/* 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. */
#include "simgrid/msg.h"
+#include "simgrid/plugins/live_migration.h"
+
+#include <stdio.h> /* snprintf */
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
@@
-84,16
+86,13
@@
static int master_fun(int argc, char *argv[])
XBT_INFO("create %s on PM(%s)", vm_name, MSG_host_get_name(pm));
msg_vm_t vm = MSG_vm_create_core(pm, vm_name);
XBT_INFO("create %s on PM(%s)", vm_name, MSG_host_get_name(pm));
msg_vm_t vm = MSG_vm_create_core(pm, vm_name);
- s_vm_params_t params;
- memset(¶ms, 0, sizeof(params));
- params.ramsize = 1L * 1024 * 1024 * 1024; // 1Gbytes
- MSG_host_set_params(vm, ¶ms);
+ MSG_vm_set_ramsize(vm, 1L * 1024 * 1024 * 1024); // 1GiB
MSG_vm_start(vm);
xbt_dynar_push(vms, &vm);
XBT_INFO("put a process (%s) on %s", pr_name, vm_name);
MSG_vm_start(vm);
xbt_dynar_push(vms, &vm);
XBT_INFO("put a process (%s) on %s", pr_name, vm_name);
- MSG_process_create(pr_name, worker_fun, NULL, vm);
+ MSG_process_create(pr_name, worker_fun, NULL,
(msg_host_t)
vm);
xbt_free(vm_name);
xbt_free(pr_name);
xbt_free(vm_name);
xbt_free(pr_name);
@@
-105,7
+104,7
@@
static int master_fun(int argc, char *argv[])
XBT_INFO("# Suspend all VMs");
xbt_dynar_foreach(vms, i, vm) {
XBT_INFO("# Suspend all VMs");
xbt_dynar_foreach(vms, i, vm) {
- XBT_INFO("suspend %s", MSG_
host
_get_name(vm));
+ XBT_INFO("suspend %s", MSG_
vm
_get_name(vm));
MSG_vm_suspend(vm);
}
MSG_vm_suspend(vm);
}
@@
-118,16
+117,16
@@
static int master_fun(int argc, char *argv[])
}
XBT_INFO("# Sleep long enough for everyone to be done with previous batch of work");
}
XBT_INFO("# Sleep long enough for everyone to be done with previous batch of work");
- MSG_process_sleep(10
00
- MSG_get_clock());
+ MSG_process_sleep(10 - MSG_get_clock());
XBT_INFO("# Add one more process on each VM");
xbt_dynar_foreach(vms, i, vm) {
unsigned int index = i + xbt_dynar_length(vms);
XBT_INFO("# Add one more process on each VM");
xbt_dynar_foreach(vms, i, vm) {
unsigned int index = i + xbt_dynar_length(vms);
- char
*vm_name = bprintf("VM%02d
", i);
- char
*pr_name = bprintf("WRK%02d
", index);
+ char
* vm_name = bprintf("VM%02u
", i);
+ char
* pr_name = bprintf("WRK%02u
", index);
XBT_INFO("put a process (%s) on %s", pr_name, vm_name);
XBT_INFO("put a process (%s) on %s", pr_name, vm_name);
- MSG_process_create(pr_name, worker_fun, NULL, vm);
+ MSG_process_create(pr_name, worker_fun, NULL,
(msg_host_t)
vm);
xbt_free(vm_name);
xbt_free(pr_name);
xbt_free(vm_name);
xbt_free(pr_name);
@@
-152,7
+151,7
@@
static int master_fun(int argc, char *argv[])
XBT_INFO("# Shutdown the half of worker processes gracefully. The remaining half will be forcibly killed.");
for (i = 0; i < nb_workers; i++) {
char mbox[MAXMBOXLEN];
XBT_INFO("# Shutdown the half of worker processes gracefully. The remaining half will be forcibly killed.");
for (i = 0; i < nb_workers; i++) {
char mbox[MAXMBOXLEN];
- snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02
d
", i);
+ snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02
u
", i);
msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
MSG_task_send(finalize, mbox);
}
msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
MSG_task_send(finalize, mbox);
}
@@
-162,9
+161,9
@@
static int master_fun(int argc, char *argv[])
XBT_INFO("# Shutdown and destroy all the VMs. The remaining worker processes will be forcibly killed.");
xbt_dynar_foreach(vms, i, vm) {
XBT_INFO("# Shutdown and destroy all the VMs. The remaining worker processes will be forcibly killed.");
xbt_dynar_foreach(vms, i, vm) {
- XBT_INFO("shutdown %s", MSG_
host
_get_name(vm));
+ XBT_INFO("shutdown %s", MSG_
vm
_get_name(vm));
MSG_vm_shutdown(vm);
MSG_vm_shutdown(vm);
- XBT_INFO("destroy %s", MSG_
host
_get_name(vm));
+ XBT_INFO("destroy %s", MSG_
vm
_get_name(vm));
MSG_vm_destroy(vm);
}
MSG_vm_destroy(vm);
}
@@
-179,7
+178,9
@@
int main(int argc, char *argv[])
const int nb_workers = 2;
MSG_init(&argc, argv);
const int nb_workers = 2;
MSG_init(&argc, argv);
- xbt_assert(argc >1,"Usage: %s example/msg/msg_platform.xml\n", argv[0]);
+ MSG_vm_live_migration_plugin_init();
+
+ xbt_assert(argc >1,"Usage: %s example/platforms/cluster.xml\n", argv[0]);
/* Load the platform file */
MSG_create_environment(argv[1]);
/* Load the platform file */
MSG_create_environment(argv[1]);