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
Change the comment of Task.setBound to fit the native semantic
[simgrid.git]
/
examples
/
msg
/
cloud
/
simple_vm.c
diff --git
a/examples/msg/cloud/simple_vm.c
b/examples/msg/cloud/simple_vm.c
index
16b4844
..
aac646c
100644
(file)
--- a/
examples/msg/cloud/simple_vm.c
+++ b/
examples/msg/cloud/simple_vm.c
@@
-1,10
+1,11
@@
-/* Copyright (c) 2007-2012. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2015. 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 <stdio.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 <stdio.h>
-#include "
msg
/msg.h"
+#include "
simgrid
/msg.h"
#include "xbt/sysdep.h" /* calloc, printf */
/* Create a log channel to have nice outputs. */
#include "xbt/sysdep.h" /* calloc, printf */
/* Create a log channel to have nice outputs. */
@@
-14,7
+15,7
@@
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
"Messages specific for this msg example");
"Messages specific for this msg example");
-int computation_fun(int argc, char *argv[])
+
static
int computation_fun(int argc, char *argv[])
{
const char *pr_name = MSG_process_get_name(MSG_process_self());
const char *host_name = MSG_host_get_name(MSG_host_self());
{
const char *pr_name = MSG_process_get_name(MSG_process_self());
const char *host_name = MSG_host_get_name(MSG_host_self());
@@
-32,7
+33,7
@@
int computation_fun(int argc, char *argv[])
return 0;
}
return 0;
}
-void launch_computation_worker(msg_host_t host)
+
static
void launch_computation_worker(msg_host_t host)
{
const char *pr_name = "compute";
char **argv = xbt_new(char *, 2);
{
const char *pr_name = "compute";
char **argv = xbt_new(char *, 2);
@@
-48,7
+49,7
@@
struct task_priv {
double clock_sta;
};
double clock_sta;
};
-int communication_tx_fun(int argc, char *argv[])
+
static
int communication_tx_fun(int argc, char *argv[])
{
xbt_assert(argc == 2);
const char *mbox = argv[1];
{
xbt_assert(argc == 2);
const char *mbox = argv[1];
@@
-67,7
+68,7
@@
int communication_tx_fun(int argc, char *argv[])
return 0;
}
return 0;
}
-int communication_rx_fun(int argc, char *argv[])
+
static
int communication_rx_fun(int argc, char *argv[])
{
const char *pr_name = MSG_process_get_name(MSG_process_self());
const char *host_name = MSG_host_get_name(MSG_host_self());
{
const char *pr_name = MSG_process_get_name(MSG_process_self());
const char *host_name = MSG_host_get_name(MSG_host_self());
@@
-85,40
+86,40
@@
int communication_rx_fun(int argc, char *argv[])
MSG_process_get_name(priv->tx_proc),
host_name, pr_name, clock_end - priv->clock_sta);
MSG_process_get_name(priv->tx_proc),
host_name, pr_name, clock_end - priv->clock_sta);
+ xbt_free(priv);
MSG_task_destroy(task);
return 0;
}
MSG_task_destroy(task);
return 0;
}
-void launch_communication_worker(msg_host_t tx_host, msg_host_t rx_host)
+
static
void launch_communication_worker(msg_host_t tx_host, msg_host_t rx_host)
{
char *mbox = bprintf("MBOX:%s-%s",
MSG_host_get_name(tx_host),
MSG_host_get_name(rx_host));
char **argv = NULL;
{
char *mbox = bprintf("MBOX:%s-%s",
MSG_host_get_name(tx_host),
MSG_host_get_name(rx_host));
char **argv = NULL;
- char *pr_name = NULL;
-
- pr_name = "comm_tx";
+
+ const char *pr_name_tx = "comm_tx";
argv = xbt_new(char *, 3);
argv = xbt_new(char *, 3);
- argv[0] = xbt_strdup(pr_name);
+ argv[0] = xbt_strdup(pr_name
_tx
);
argv[1] = xbt_strdup(mbox);
argv[2] = NULL;
argv[1] = xbt_strdup(mbox);
argv[2] = NULL;
- MSG_process_create_with_arguments(pr_name, communication_tx_fun, NULL, tx_host, 2, argv);
+ MSG_process_create_with_arguments(pr_name
_tx
, communication_tx_fun, NULL, tx_host, 2, argv);
- pr_name = "comm_rx";
+ const char *pr_name_rx = "comm_rx";
argv = xbt_new(char *, 3);
argv = xbt_new(char *, 3);
- argv[0] = xbt_strdup(pr_name);
+ argv[0] = xbt_strdup(pr_name
_rx
);
argv[1] = xbt_strdup(mbox);
argv[2] = NULL;
argv[1] = xbt_strdup(mbox);
argv[2] = NULL;
- MSG_process_create_with_arguments(pr_name, communication_rx_fun, NULL, rx_host, 2, argv);
+ MSG_process_create_with_arguments(pr_name
_rx
, communication_rx_fun, NULL, rx_host, 2, argv);
xbt_free(mbox);
}
xbt_free(mbox);
}
-int master_main(int argc, char *argv[])
+
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);
{
xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t);
@@
-253,6
+254,12
@@
int master_main(int argc, char *argv[])
XBT_INFO("## Test 6 (started): Check migration impact (not yet implemented neither on the CPU resource nor on the network one");
XBT_INFO("### Relocate VM0 between PM0 and PM1");
vm0 = MSG_vm_create_core(pm0, "VM0");
XBT_INFO("## Test 6 (started): Check migration impact (not yet implemented neither on the CPU resource nor on the network one");
XBT_INFO("### Relocate VM0 between PM0 and PM1");
vm0 = MSG_vm_create_core(pm0, "VM0");
+ {
+ s_vm_params_t params;
+ memset(¶ms, 0, sizeof(params));
+ params.ramsize = 1L * 1024 * 1024 * 1024; // 1Gbytes
+ MSG_host_set_params(vm0, ¶ms);
+ }
MSG_vm_start(vm0);
launch_communication_worker(vm0, pm2);
MSG_process_sleep(0.01);
MSG_vm_start(vm0);
launch_communication_worker(vm0, pm2);
MSG_process_sleep(0.01);
@@
-263,17
+270,18
@@
int master_main(int argc, char *argv[])
MSG_vm_destroy(vm0);
XBT_INFO("## Test 6 (ended)");
MSG_vm_destroy(vm0);
XBT_INFO("## Test 6 (ended)");
+ xbt_dynar_free(&hosts_dynar);
return 0;
}
return 0;
}
-void launch_master(msg_host_t host)
+
static
void launch_master(msg_host_t host)
{
const char *pr_name = "master_";
char **argv = xbt_new(char *, 2);
argv[0] = xbt_strdup(pr_name);
argv[1] = NULL;
{
const char *pr_name = "master_";
char **argv = xbt_new(char *, 2);
argv[0] = xbt_strdup(pr_name);
argv[1] = NULL;
-
msg_process_t pr =
MSG_process_create_with_arguments(pr_name, master_main, NULL, host, 1, argv);
+ MSG_process_create_with_arguments(pr_name, master_main, NULL, host, 1, argv);
}
}
@@
-283,6
+291,7
@@
int main(int argc, char *argv[])
MSG_init(&argc, argv);
/* load the platform file */
MSG_init(&argc, argv);
/* load the platform file */
+ xbt_assert(argc == 2);
MSG_create_environment(argv[1]);
xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
MSG_create_environment(argv[1]);
xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
@@
-290,9
+299,8
@@
int main(int argc, char *argv[])
launch_master(pm0);
int res = MSG_main();
launch_master(pm0);
int res = MSG_main();
- XBT_INFO("Simulation time %g", MSG_get_clock());
-
- XBT_INFO("bye");
+ XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
+ xbt_dynar_free(&hosts_dynar);
- return
0
;
+ return
!(res == MSG_OK)
;
}
}