Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge remote-tracking branch 'origin/master'
[simgrid.git] / examples / msg / masterslave / masterslave_arg.c
index e1cd7f3..4fd570a 100644 (file)
@@ -23,7 +23,8 @@ int slave(int argc, char *argv[]);
 long number_of_jobs;
 long number_of_slaves;
 
-long my_random(long n) {
+static long my_random(long n)
+{
   return n * (rand() / ((double)RAND_MAX + 1));
 }
 
@@ -67,7 +68,6 @@ int slave(int argc, char *argv[])
 {
   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) {
@@ -95,14 +95,13 @@ int main(int argc, char *argv[])
   MSG_error_t res = MSG_OK;
   long i;
 
-  MSG_global_init(&argc, argv);
+  MSG_init(&argc, argv);
   if (argc < 4) {
     printf("Usage: %s platform_file number_of_jobs number_of_slaves\n", argv[0]);
     printf("example: %s msg_platform.xml 10 5\n", argv[0]);
     exit(1);
   }
 
-  MSG_set_channel_number(0);
   MSG_function_register("master", master);
   MSG_function_register("slave", slave);
 
@@ -110,10 +109,12 @@ int main(int argc, char *argv[])
 
   number_of_jobs = atol(argv[2]);
   number_of_slaves = atol(argv[3]);
-  long number_max = MSG_get_host_number();
-  XBT_INFO("Got %ld slaves, %ld tasks to process, and %d hosts", number_of_slaves, number_of_jobs,MSG_get_host_number());
+  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);
 
-  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,