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
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot//simgrid/simgrid
[simgrid.git]
/
examples
/
msg
/
masterslave
/
masterslave_arg.c
diff --git
a/examples/msg/masterslave/masterslave_arg.c
b/examples/msg/masterslave/masterslave_arg.c
index
a8dbf97
..
58c7d7b
100644
(file)
--- a/
examples/msg/masterslave/masterslave_arg.c
+++ b/
examples/msg/masterslave/masterslave_arg.c
@@
-23,8
+23,9
@@
int slave(int argc, char *argv[]);
long number_of_jobs;
long number_of_slaves;
long number_of_jobs;
long number_of_slaves;
-long my_random(long n) {
- return n*(rand()/(RAND_MAX+1));
+static long my_random(long n)
+{
+ return n * (rand() / ((double)RAND_MAX + 1));
}
/** Emitter function */
}
/** Emitter function */
@@
-67,7
+68,6
@@
int slave(int argc, char *argv[])
{
m_task_t task = NULL;
_XBT_GNUC_UNUSED int res;
{
m_task_t task = NULL;
_XBT_GNUC_UNUSED int res;
- int id = -1;
XBT_DEBUG("mailbox: %s",MSG_process_get_name(MSG_process_self()));
while (1) {
XBT_DEBUG("mailbox: %s",MSG_process_get_name(MSG_process_self()));
while (1) {
@@
-102,7
+102,6
@@
int main(int argc, char *argv[])
exit(1);
}
exit(1);
}
- MSG_set_channel_number(0);
MSG_function_register("master", master);
MSG_function_register("slave", slave);
MSG_function_register("master", master);
MSG_function_register("slave", slave);
@@
-110,15
+109,17
@@
int main(int argc, char *argv[])
number_of_jobs = atol(argv[2]);
number_of_slaves = atol(argv[3]);
number_of_jobs = atol(argv[2]);
number_of_slaves = atol(argv[3]);
+ xbt_dynar_t host_dynar = MSG_hosts_as_dynar();
+ long number_max = xbt_dynar_length(host_dynar);
+ XBT_INFO("Got %ld slaves, %ld tasks to process, and %ld hosts", number_of_slaves, number_of_jobs,number_max);
- XBT_INFO("Got %ld slaves, %ld tasks to process, and %d hosts", number_of_slaves, number_of_jobs,MSG_get_host_number());
-
- m_host_t *host_table = MSG_get_host_table();
+ m_host_t *host_table = xbt_dynar_to_array(host_dynar);
+ //xbt_dynar_free(&host_dynar);
MSG_process_create( "master",
master,
NULL,
MSG_process_create( "master",
master,
NULL,
- host_table[my_random(number_
of_slaves
)]
+ host_table[my_random(number_
max
)]
);
for(i = 0 ; i<number_of_slaves; i++)
);
for(i = 0 ; i<number_of_slaves; i++)
@@
-127,7
+128,7
@@
int main(int argc, char *argv[])
MSG_process_create( name_host,
slave,
NULL,
MSG_process_create( name_host,
slave,
NULL,
- host_table[my_random(number_
of_slaves
)]
+ host_table[my_random(number_
max
)]
);
free(name_host);
}
);
free(name_host);
}