Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
yet another cleaning pass
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 29 Feb 2016 10:44:22 +0000 (11:44 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 29 Feb 2016 10:45:27 +0000 (11:45 +0100)
  + still some work to do in chord and pastry

53 files changed:
examples/msg/README
examples/msg/actions/actions.c
examples/msg/actions/storage_actions.c
examples/msg/bittorrent/connection.c
examples/msg/chainsend/CMakeLists.txt
examples/msg/chainsend/README [deleted file]
examples/msg/chainsend/broadcaster.c
examples/msg/chainsend/broadcaster.h
examples/msg/chainsend/chainsend.c
examples/msg/chainsend/common.h
examples/msg/chainsend/iterator.h
examples/msg/chainsend/messages.h
examples/msg/chainsend/peer.c
examples/msg/chainsend/peer.h
examples/msg/chord/chord.c
examples/msg/cloud/master_worker_vm.c
examples/msg/cloud/master_worker_vm.tesh
examples/msg/cloud/migrate_vm.c
examples/msg/cloud/multicore.c
examples/msg/cloud/scale.c
examples/msg/cloud/simple_vm.c
examples/msg/cloud/two_tasks_vm.c
examples/msg/energy/consumption/energy_consumption.c
examples/msg/energy/onoff/onoff.c
examples/msg/energy/pstate/pstate.c
examples/msg/energy/vm/CMakeLists.txt
examples/msg/energy/vm/deployment_consumption.xml [deleted file]
examples/msg/energy/vm/energy_vm.c
examples/msg/exception/exception.c
examples/msg/gpu/test_MSG_gpu_task_create.c
examples/msg/gtnets/gtnets.c
examples/msg/icomms/peer.c
examples/msg/icomms/peer2.c
examples/msg/icomms/peer3.c
examples/msg/io/file.c
examples/msg/io/file_unlink.c
examples/msg/io/remote.c
examples/msg/io/storage.c
examples/msg/kademlia/kademlia.c
examples/msg/kademlia/node.c
examples/msg/kademlia/routing_table.c
examples/msg/masterslave/masterslave_arg.c
examples/msg/masterslave/masterslave_failure.c
examples/msg/masterslave/masterslave_forwarder.c
examples/msg/masterslave/masterslave_kill.c
examples/msg/masterslave/masterslave_mailbox.c
examples/msg/migration/migration.c
examples/msg/ns3/ns3.c
examples/msg/parallel_task/parallel_task.c
examples/msg/pastry/pastry.c
examples/msg/pmm/msg_pmm.c
examples/msg/semaphores/synchro.c
examples/msg/start_kill_time/sk_time.c

index ecdfac5..58db3bd 100644 (file)
@@ -57,7 +57,7 @@ communications, there is several other examples in the archive:
  * msg/icomms/peer2.c: demonstrates the MSG_comm_waitall() function
  * msg/icomms/peer3.c: demonstrates the MSG_comm_waitany() function
 
  * msg/icomms/peer2.c: demonstrates the MSG_comm_waitall() function
  * msg/icomms/peer3.c: demonstrates the MSG_comm_waitany() function
 
-Tracing and vizualization features
+Tracing and visualization features
 ==================================
  * tracing/simple.c very simple program that creates, executes and
    destroy a task
 ==================================
  * tracing/simple.c very simple program that creates, executes and
    destroy a task
index f8b1b88..df86b80 100644 (file)
@@ -4,9 +4,7 @@
 /* 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. */
 
 /* 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 <stdlib.h>
-#include "simgrid/msg.h"        /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
+#include "simgrid/msg.h"
 #include "simgrid/simix.h"      /* semaphores for the barrier */
 #include <xbt/replay.h>
 
 #include "simgrid/simix.h"      /* semaphores for the barrier */
 #include <xbt/replay.h>
 
  *
  *  @section MSG_ex_actions Trace driven simulations
  * 
  *
  *  @section MSG_ex_actions Trace driven simulations
  * 
- *  The <b>actions/actions.c</b> example demonstrates how to run trace-driven simulations. It
- *  is very handy when you want to test an algorithm or protocol that
- *  does nothing unless it receives some events from outside. For
- *  example, a P2P protocol reacts to requests from the user, but
- *  does nothing if there is no such event. 
+ *  The <b>actions/actions.c</b> example demonstrates how to run trace-driven simulations. It is very handy when you
+ *  want to test an algorithm or protocol that does nothing unless it receives some events from outside. For example,
+ *  a P2P protocol reacts to requests from the user, but does nothing if there is no such event.
  * 
  * 
- *  In such situations, SimGrid allows to write your protocol in your
- *  C file, and the events to react to in a separate text file.
- *  Declare a function handling each of the events that you want to
- *  accept in your trace files, register them using \ref
- *  xbt_replay_action_register in your main, and then use \ref
- *  MSG_action_trace_run to launch the simulation. You can either
- *  have one trace file containing all your events, or a file per
- *  simulated process. Check the tesh files in the example directory
- *  for details on how to do it.
+ *  In such situations, SimGrid allows to write your protocol in your C file, and the events to react to in a separate
+ *  text file. Declare a function handling each of the events that you want to accept in your trace files, register
+ *  them using \ref xbt_replay_action_register in your main, and then use \ref MSG_action_trace_run to launch the
+ *  simulation. You can either have one trace file containing all your events, or a file per simulated process. Check
+ *  the tesh files in the example directory for details on how to do it.
  *
  *
- *  This example uses this approach to replay MPI-like traces. It
- *  comes with a set of event handlers reproducing MPI events. This
- *  is somehow similar to SMPI, yet differently implemented. This
- *  code should probably be changed to use SMPI internals instead,
- *  but wasn't, so far.
- * 
+ *  This example uses this approach to replay MPI-like traces. It comes with a set of event handlers reproducing MPI
+ *  events. This is somehow similar to SMPI, yet differently implemented. This code should probably be changed to use
+ *  SMPI internals instead, but wasn't, so far.
  */
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(actions, "Messages specific for this msg example");
  */
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(actions, "Messages specific for this msg example");
@@ -84,8 +73,7 @@ static void log_action(const char *const *action, double date)
 
 static void asynchronous_cleanup(void)
 {
 
 static void asynchronous_cleanup(void)
 {
-  process_globals_t globals =
-      (process_globals_t) MSG_process_get_data(MSG_process_self());
+  process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self());
 
   /* Destroy any isend which correspond to completed communications */
   int found;
 
   /* Destroy any isend which correspond to completed communications */
   int found;
@@ -102,7 +90,7 @@ static void action_send(const char *const *action)
   char to[250];
   const char *size_str = action[3];
   double size = parse_double(size_str);
   char to[250];
   const char *size_str = action[3];
   double size = parse_double(size_str);
-  double clock = MSG_get_clock();       /* this "call" is free thanks to inlining */
+  double clock = MSG_get_clock();
 
   sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]);
 
 
   sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]);
 
@@ -122,12 +110,10 @@ static void action_Isend(const char *const *action)
   char to[250];
   const char *size = action[3];
   double clock = MSG_get_clock();
   char to[250];
   const char *size = action[3];
   double clock = MSG_get_clock();
-  process_globals_t globals =
-      (process_globals_t) MSG_process_get_data(MSG_process_self());
+  process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self());
 
   sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]);
 
   sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]);
-  msg_comm_t comm =
-      MSG_task_isend(MSG_task_create(to, 0, parse_double(size), NULL), to);
+  msg_comm_t comm = MSG_task_isend(MSG_task_create(to, 0, parse_double(size), NULL), to);
   xbt_dynar_push(globals->isends, &comm);
 
   XBT_DEBUG("Isend on %s", MSG_process_get_name(MSG_process_self()));
   xbt_dynar_push(globals->isends, &comm);
 
   XBT_DEBUG("Isend on %s", MSG_process_get_name(MSG_process_self()));
@@ -135,15 +121,13 @@ static void action_Isend(const char *const *action)
   asynchronous_cleanup();
 }
 
   asynchronous_cleanup();
 }
 
-
 static void action_recv(const char *const *action)
 {
   char mailbox_name[250];
   msg_task_t task = NULL;
   double clock = MSG_get_clock();
 
 static void action_recv(const char *const *action)
 {
   char mailbox_name[250];
   msg_task_t task = NULL;
   double clock = MSG_get_clock();
 
-  sprintf(mailbox_name, "%s_%s", action[2],
-          MSG_process_get_name(MSG_process_self()));
+  sprintf(mailbox_name, "%s_%s", action[2], MSG_process_get_name(MSG_process_self()));
 
   ACT_DEBUG("Receiving: %s", NAME);
   msg_error_t res = MSG_task_receive(&task, mailbox_name);
 
   ACT_DEBUG("Receiving: %s", NAME);
   msg_error_t res = MSG_task_receive(&task, mailbox_name);
@@ -159,36 +143,28 @@ static void action_Irecv(const char *const *action)
 {
   char mailbox[250];
   double clock = MSG_get_clock();
 {
   char mailbox[250];
   double clock = MSG_get_clock();
-  process_globals_t globals =
-      (process_globals_t) MSG_process_get_data(MSG_process_self());
+  process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self());
 
   XBT_DEBUG("Irecv on %s", MSG_process_get_name(MSG_process_self()));
 
 
   XBT_DEBUG("Irecv on %s", MSG_process_get_name(MSG_process_self()));
 
-  sprintf(mailbox, "%s_%s", action[2],
-          MSG_process_get_name(MSG_process_self()));
+  sprintf(mailbox, "%s_%s", action[2], MSG_process_get_name(MSG_process_self()));
   msg_task_t t = NULL;
   xbt_dynar_push(globals->tasks, &t);
   msg_task_t t = NULL;
   xbt_dynar_push(globals->tasks, &t);
-  msg_comm_t c =
-      MSG_task_irecv(xbt_dynar_get_ptr
-                     (globals->tasks, xbt_dynar_length(globals->tasks) - 1),
-                     mailbox);
+  msg_comm_t c = MSG_task_irecv(xbt_dynar_get_ptr(globals->tasks, xbt_dynar_length(globals->tasks) - 1), mailbox);
   xbt_dynar_push(globals->irecvs, &c);
 
   log_action(action, MSG_get_clock() - clock);
   asynchronous_cleanup();
 }
 
   xbt_dynar_push(globals->irecvs, &c);
 
   log_action(action, MSG_get_clock() - clock);
   asynchronous_cleanup();
 }
 
-
 static void action_wait(const char *const *action)
 {
   msg_task_t task = NULL;
   msg_comm_t comm;
   double clock = MSG_get_clock();
 static void action_wait(const char *const *action)
 {
   msg_task_t task = NULL;
   msg_comm_t comm;
   double clock = MSG_get_clock();
-  process_globals_t globals =
-      (process_globals_t) MSG_process_get_data(MSG_process_self());
+  process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self());
 
 
-  xbt_assert(xbt_dynar_length(globals->irecvs),
-             "action wait not preceded by any irecv: %s",
+  xbt_assert(xbt_dynar_length(globals->irecvs), "action wait not preceded by any irecv: %s",
              xbt_str_join_array(action, " "));
 
   ACT_DEBUG("Entering %s", NAME);
              xbt_str_join_array(action, " "));
 
   ACT_DEBUG("Entering %s", NAME);
@@ -213,8 +189,7 @@ static void action_barrier(const char *const *action)
     cond = simcall_cond_init();
     processes_arrived_sofar = 0;
   }
     cond = simcall_cond_init();
     processes_arrived_sofar = 0;
   }
-  ACT_DEBUG("Entering barrier: %s (%d already there)", NAME,
-            processes_arrived_sofar);
+  ACT_DEBUG("Entering barrier: %s (%d already there)", NAME, processes_arrived_sofar);
 
   simcall_mutex_lock(mutex);
   if (++processes_arrived_sofar == communicator_size) {
 
   simcall_mutex_lock(mutex);
   if (++processes_arrived_sofar == communicator_size) {
@@ -246,11 +221,9 @@ static void action_reduce(const char *const *action)
   const char *process_name;
   double clock = MSG_get_clock();
 
   const char *process_name;
   double clock = MSG_get_clock();
 
-  process_globals_t counters =
-      (process_globals_t) MSG_process_get_data(MSG_process_self());
+  process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self());
 
 
-  xbt_assert(communicator_size, "Size of Communicator is not defined, "
-             "can't use collective operations");
+  xbt_assert(communicator_size, "Size of Communicator is not defined can't use collective operations");
 
   process_name = MSG_process_get_name(MSG_process_self());
 
 
   process_name = MSG_process_get_name(MSG_process_self());
 
@@ -278,13 +251,11 @@ static void action_reduce(const char *const *action)
     MSG_task_execute(comp_task);
     MSG_task_destroy(comp_task);
     XBT_DEBUG("%s: computed", reduce_identifier);
     MSG_task_execute(comp_task);
     MSG_task_destroy(comp_task);
     XBT_DEBUG("%s: computed", reduce_identifier);
-
   } else {
     XBT_DEBUG("%s: %s sends", reduce_identifier, process_name);
     sprintf(mailbox, "%s_%s_p0", reduce_identifier, process_name);
     XBT_DEBUG("put on %s", mailbox);
   } else {
     XBT_DEBUG("%s: %s sends", reduce_identifier, process_name);
     sprintf(mailbox, "%s_%s_p0", reduce_identifier, process_name);
     XBT_DEBUG("put on %s", mailbox);
-    MSG_task_send(MSG_task_create(reduce_identifier, 0, comm_size, NULL),
-                  mailbox);
+    MSG_task_send(MSG_task_create(reduce_identifier, 0, comm_size, NULL), mailbox);
   }
 
   log_action(action, MSG_get_clock() - clock);
   }
 
   log_action(action, MSG_get_clock() - clock);
@@ -301,11 +272,9 @@ static void action_bcast(const char *const *action)
   const char *process_name;
   double clock = MSG_get_clock();
 
   const char *process_name;
   double clock = MSG_get_clock();
 
-  process_globals_t counters =
-      (process_globals_t) MSG_process_get_data(MSG_process_self());
+  process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self());
 
 
-  xbt_assert(communicator_size, "Size of Communicator is not defined, "
-             "can't use collective operations");
+  xbt_assert(communicator_size, "Size of Communicator is not defined, can't use collective operations");
 
   process_name = MSG_process_get_name(MSG_process_self());
 
 
   process_name = MSG_process_get_name(MSG_process_self());
 
@@ -318,17 +287,14 @@ static void action_bcast(const char *const *action)
 
     for (i = 1; i < communicator_size; i++) {
       sprintf(mailbox, "%s_p0_p%d", bcast_identifier, i);
 
     for (i = 1; i < communicator_size; i++) {
       sprintf(mailbox, "%s_p0_p%d", bcast_identifier, i);
-      comms[i - 1] =
-          MSG_task_isend(MSG_task_create(mailbox, 0, comm_size, NULL), mailbox);
+      comms[i - 1] = MSG_task_isend(MSG_task_create(mailbox, 0, comm_size, NULL), mailbox);
     }
     MSG_comm_waitall(comms, communicator_size - 1, -1);
     for (i = 1; i < communicator_size; i++)
       MSG_comm_destroy(comms[i - 1]);
     xbt_free(comms);
 
     }
     MSG_comm_waitall(comms, communicator_size - 1, -1);
     for (i = 1; i < communicator_size; i++)
       MSG_comm_destroy(comms[i - 1]);
     xbt_free(comms);
 
-    XBT_DEBUG("%s: all messages sent by %s have been received",
-              bcast_identifier, process_name);
-
+    XBT_DEBUG("%s: all messages sent by %s have been received", bcast_identifier, process_name);
   } else {
     sprintf(mailbox, "%s_p0_%s", bcast_identifier, process_name);
     MSG_task_receive(&task, mailbox);
   } else {
     sprintf(mailbox, "%s_p0_%s", bcast_identifier, process_name);
     MSG_task_receive(&task, mailbox);
@@ -340,7 +306,6 @@ static void action_bcast(const char *const *action)
   xbt_free(bcast_identifier);
 }
 
   xbt_free(bcast_identifier);
 }
 
-
 static void action_sleep(const char *const *action)
 {
   const char *duration = action[2];
 static void action_sleep(const char *const *action)
 {
   const char *duration = action[2];
@@ -362,11 +327,9 @@ static void action_allReduce(const char *const *action)
   const char *process_name;
   double clock = MSG_get_clock();
 
   const char *process_name;
   double clock = MSG_get_clock();
 
-  process_globals_t counters =
-      (process_globals_t) MSG_process_get_data(MSG_process_self());
+  process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self());
 
 
-  xbt_assert(communicator_size, "Size of Communicator is not defined, "
-             "can't use collective operations");
+  xbt_assert(communicator_size, "Size of Communicator is not defined, can't use collective operations");
 
   process_name = MSG_process_get_name(MSG_process_self());
 
 
   process_name = MSG_process_get_name(MSG_process_self());
 
@@ -396,23 +359,19 @@ static void action_allReduce(const char *const *action)
 
     for (i = 1; i < communicator_size; i++) {
       sprintf(mailbox, "%s_p0_p%d", allreduce_identifier, i);
 
     for (i = 1; i < communicator_size; i++) {
       sprintf(mailbox, "%s_p0_p%d", allreduce_identifier, i);
-      comms[i - 1] =
-          MSG_task_isend(MSG_task_create(mailbox, 0, comm_size, NULL), mailbox);
+      comms[i - 1] = MSG_task_isend(MSG_task_create(mailbox, 0, comm_size, NULL), mailbox);
     }
     MSG_comm_waitall(comms, communicator_size - 1, -1);
     for (i = 1; i < communicator_size; i++)
       MSG_comm_destroy(comms[i - 1]);
     xbt_free(comms);
 
     }
     MSG_comm_waitall(comms, communicator_size - 1, -1);
     for (i = 1; i < communicator_size; i++)
       MSG_comm_destroy(comms[i - 1]);
     xbt_free(comms);
 
-    XBT_DEBUG("%s: all messages sent by %s have been received",
-              allreduce_identifier, process_name);
-
+    XBT_DEBUG("%s: all messages sent by %s have been received", allreduce_identifier, process_name);
   } else {
     XBT_DEBUG("%s: %s sends", allreduce_identifier, process_name);
     sprintf(mailbox, "%s_%s_p0", allreduce_identifier, process_name);
     XBT_DEBUG("put on %s", mailbox);
   } else {
     XBT_DEBUG("%s: %s sends", allreduce_identifier, process_name);
     sprintf(mailbox, "%s_%s_p0", allreduce_identifier, process_name);
     XBT_DEBUG("put on %s", mailbox);
-    MSG_task_send(MSG_task_create(allreduce_identifier, 0, comm_size, NULL),
-                  mailbox);
+    MSG_task_send(MSG_task_create(allreduce_identifier, 0, comm_size, NULL), mailbox);
 
     sprintf(mailbox, "%s_p0_%s", allreduce_identifier, process_name);
     MSG_task_receive(&task, mailbox);
 
     sprintf(mailbox, "%s_p0_%s", allreduce_identifier, process_name);
     MSG_task_receive(&task, mailbox);
@@ -448,19 +407,16 @@ static void action_compute(const char *const *action)
 static void action_init(const char *const *action)
 {
   XBT_DEBUG("Initialize the counters");
 static void action_init(const char *const *action)
 {
   XBT_DEBUG("Initialize the counters");
-  process_globals_t globals =
-      (process_globals_t) calloc(1, sizeof(s_process_globals_t));
+  process_globals_t globals = (process_globals_t) calloc(1, sizeof(s_process_globals_t));
   globals->isends = xbt_dynar_new(sizeof(msg_comm_t), NULL);
   globals->irecvs = xbt_dynar_new(sizeof(msg_comm_t), NULL);
   globals->tasks = xbt_dynar_new(sizeof(msg_task_t), NULL);
   MSG_process_set_data(MSG_process_self(), globals);
   globals->isends = xbt_dynar_new(sizeof(msg_comm_t), NULL);
   globals->irecvs = xbt_dynar_new(sizeof(msg_comm_t), NULL);
   globals->tasks = xbt_dynar_new(sizeof(msg_task_t), NULL);
   MSG_process_set_data(MSG_process_self(), globals);
-
 }
 
 static void action_finalize(const char *const *action)
 {
 }
 
 static void action_finalize(const char *const *action)
 {
-  process_globals_t globals =
-      (process_globals_t) MSG_process_get_data(MSG_process_self());
+  process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self());
   if (globals) {
     asynchronous_cleanup();
     xbt_dynar_free_container(&(globals->isends));
   if (globals) {
     asynchronous_cleanup();
     xbt_dynar_free_container(&(globals->isends));
@@ -489,14 +445,10 @@ int main(int argc, char *argv[])
        argv[0],argv[0],argv[0]);
 
   printf("WARNING: THIS BINARY IS KINDA DEPRECATED\n"
        argv[0],argv[0],argv[0]);
 
   printf("WARNING: THIS BINARY IS KINDA DEPRECATED\n"
-   "This example is still relevant if you want to learn about MSG-based trace replay, "
-   "but if you want to simulate MPI-like traces, you should use the newer version "
-   "that is in the examples/smpi/replay directory instead.\n");
+   "This example is still relevant if you want to learn about MSG-based trace replay, but if you want to simulate "
+   "MPI-like traces, you should use the newer version that is in the examples/smpi/replay directory instead.\n");
    
    
-  /*  Simulation setting */
   MSG_create_environment(argv[1]);
   MSG_create_environment(argv[1]);
-
-  /* No need to register functions as in classical MSG programs: the actions get started anyway */
   MSG_launch_application(argv[2]);
 
   /*   Action registration */
   MSG_launch_application(argv[2]);
 
   /*   Action registration */
@@ -515,7 +467,6 @@ int main(int argc, char *argv[])
   xbt_replay_action_register("sleep", action_sleep);
   xbt_replay_action_register("compute", action_compute);
 
   xbt_replay_action_register("sleep", action_sleep);
   xbt_replay_action_register("compute", action_compute);
 
-
   /* Actually do the simulation using MSG_action_trace_run */
   res = MSG_action_trace_run(argv[3]);  // it's ok to pass a NULL argument here
 
   /* Actually do the simulation using MSG_action_trace_run */
   res = MSG_action_trace_run(argv[3]);  // it's ok to pass a NULL argument here
 
@@ -525,4 +476,4 @@ int main(int argc, char *argv[])
   MSG_action_exit();
 
   return res != MSG_OK;
   MSG_action_exit();
 
   return res != MSG_OK;
-}                               /* end_of_main */
+}
index aa1ef5b..0d29d49 100644 (file)
@@ -4,10 +4,7 @@
 /* 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. */
 
 /* 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 <stdlib.h>
 #include "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt.h"                /* calloc, printf */
 #include <xbt/replay.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage_actions, "Messages specific for this example");
 #include <xbt/replay.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage_actions, "Messages specific for this example");
@@ -43,28 +40,26 @@ static msg_file_t get_file_descriptor(const char *file_name){
 static sg_size_t parse_size(const char *string){
   sg_size_t size;
   char *endptr;
 static sg_size_t parse_size(const char *string){
   sg_size_t size;
   char *endptr;
-  
+
   size = strtoul(string, &endptr, 10);
   if (*endptr != '\0')
     THROWF(unknown_error, 0, "%s is not a long unsigned int (a.k.a. sg_size_t)", string);
   return size;
 }
 
   size = strtoul(string, &endptr, 10);
   if (*endptr != '\0')
     THROWF(unknown_error, 0, "%s is not a long unsigned int (a.k.a. sg_size_t)", string);
   return size;
 }
 
-
 static void action_open(const char *const *action) {
   const char *file_name = action[2];
   char full_name[1024];
   msg_file_t file = NULL;
 static void action_open(const char *const *action) {
   const char *file_name = action[2];
   char full_name[1024];
   msg_file_t file = NULL;
-  double clock = MSG_get_clock();       /* this "call" is free thanks to inlining */
+  double clock = MSG_get_clock();
 
 
-  sprintf(full_name, "%s:%s", MSG_process_get_name(MSG_process_self()), 
-    file_name);
+  sprintf(full_name, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name);
 
   ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name);
   file = MSG_file_open(file_name, NULL);
 
   ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name);
   file = MSG_file_open(file_name, NULL);
+
   xbt_dict_set(opened_files, full_name, file, NULL);
   xbt_dict_set(opened_files, full_name, file, NULL);
-  
+
   log_action(action, MSG_get_clock() - clock);
 }
 
   log_action(action, MSG_get_clock() - clock);
 }
 
@@ -73,11 +68,11 @@ static void action_read(const char *const *action) {
   const char *size_str = action[3];
   msg_file_t file = NULL;
   sg_size_t size = parse_size(size_str);
   const char *size_str = action[3];
   msg_file_t file = NULL;
   sg_size_t size = parse_size(size_str);
-  
-  double clock = MSG_get_clock();       /* this "call" is free thanks to inlining */
+
+  double clock = MSG_get_clock();
 
   file = get_file_descriptor(file_name);
 
   file = get_file_descriptor(file_name);
-  
+
   ACT_DEBUG("Entering Read: %s (size: %llu)", NAME, size);
   MSG_file_read(file, size);
 
   ACT_DEBUG("Entering Read: %s (size: %llu)", NAME, size);
   MSG_file_read(file, size);
 
@@ -87,7 +82,7 @@ static void action_read(const char *const *action) {
 static void action_close(const char *const *action) {
   const char *file_name = action[2];
   msg_file_t file;
 static void action_close(const char *const *action) {
   const char *file_name = action[2];
   msg_file_t file;
-  double clock = MSG_get_clock();       /* this "call" is free thanks to inlining */
+  double clock = MSG_get_clock();
 
   file = get_file_descriptor(file_name);
 
 
   file = get_file_descriptor(file_name);
 
@@ -100,33 +95,23 @@ static void action_close(const char *const *action) {
 int main(int argc, char *argv[]) {
   msg_error_t res = MSG_OK;
 
 int main(int argc, char *argv[]) {
   msg_error_t res = MSG_OK;
 
-  /* Check the given arguments */
   MSG_init(&argc, argv);
   /* Explicit initialization of the action module is required now*/
   MSG_action_init();
 
   MSG_init(&argc, argv);
   /* Explicit initialization of the action module is required now*/
   MSG_action_init();
 
-  if (argc < 3) {
-    printf("Usage: %s platform_file deployment_file [action_files]\n", argv[0]);
-    printf
-        ("example: %s msg_platform.xml msg_deployment.xml actions # if all actions are in the same file\n",
-         argv[0]);
-    printf
-        ("example: %s msg_platform.xml msg_deployment.xml # if actions are in separate files, specified in deployment\n",
-         argv[0]);
-    exit(1);
-  }
+  xbt_assert(argc > 3,"Usage: %s platform_file deployment_file [action_files]\n"
+             "\texample: %s platform.xml deployment.xml actions # if all actions are in the same file\n"
+             "\texample: %s platform.xml deployment.xml # if actions are in separate files, specified in deployment\n",
+             argv[0], argv[0], argv[0]);
 
 
-  /*  Simulation setting */
   MSG_create_environment(argv[1]);
   MSG_create_environment(argv[1]);
-
-  /* No need to register functions as in classical MSG programs: the actions get started anyway */
   MSG_launch_application(argv[2]);
 
   /*   Action registration */
   xbt_replay_action_register("open", action_open);
   xbt_replay_action_register("read", action_read);
   xbt_replay_action_register("close", action_close);
   MSG_launch_application(argv[2]);
 
   /*   Action registration */
   xbt_replay_action_register("open", action_open);
   xbt_replay_action_register("read", action_read);
   xbt_replay_action_register("close", action_close);
-  
+
   if (!opened_files)
     opened_files = xbt_dict_new_homogeneous(NULL);
   /* Actually do the simulation using MSG_action_trace_run */
   if (!opened_files)
     opened_files = xbt_dict_new_homogeneous(NULL);
   /* Actually do the simulation using MSG_action_trace_run */
@@ -140,5 +125,5 @@ int main(int argc, char *argv[]) {
   /* Explicit finalization of the action module is required now*/
   MSG_action_exit();
 
   /* Explicit finalization of the action module is required now*/
   MSG_action_exit();
 
-  return !!res;
-}                               /* end_of_main */
+  return res!=MSG_OK;
+}
index c0ee2a5..847a6c4 100644 (file)
@@ -38,5 +38,4 @@ void connection_free(void *data)
   xbt_free(co->bitfield);
   xbt_free(co->mailbox);
   xbt_free(co);
   xbt_free(co->bitfield);
   xbt_free(co->mailbox);
   xbt_free(co);
-
 }
 }
index 773c0cb..b90e420 100644 (file)
@@ -23,10 +23,3 @@ set(examples_src
   ${CMAKE_CURRENT_SOURCE_DIR}/peer.c
   ${CMAKE_CURRENT_SOURCE_DIR}/chainsend.c
   PARENT_SCOPE)
   ${CMAKE_CURRENT_SOURCE_DIR}/peer.c
   ${CMAKE_CURRENT_SOURCE_DIR}/chainsend.c
   PARENT_SCOPE)
-set(bin_files
-  ${bin_files}
-  PARENT_SCOPE)
-set(txt_files
-  ${txt_files}
-  ${CMAKE_CURRENT_SOURCE_DIR}/README
-  PARENT_SCOPE)
diff --git a/examples/msg/chainsend/README b/examples/msg/chainsend/README
deleted file mode 100644 (file)
index 17b605b..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-This directory contains a MSG implementation of a file broadcasting
-system, similar to Kastafior (from the Kadeploy).
index 112bb25..f14a1be 100644 (file)
@@ -6,8 +6,7 @@
 
 #include "broadcaster.h"
 
 
 #include "broadcaster.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_broadcaster,
-                             "Messages specific for the broadcaster");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_broadcaster, "Messages specific for the broadcaster");
 
 xbt_dynar_t build_hostlist_from_hostcount(int hostcount)
 {
 
 xbt_dynar_t build_hostlist_from_hostcount(int hostcount)
 {
@@ -38,8 +37,7 @@ int broadcaster_build_chain(broadcaster_t bc)
     next = *cur;
     bc->first = next;
 
     next = *cur;
     bc->first = next;
 
-    /* This iterator iterates one step ahead: cur is current iterated element, 
-       but it's actually the next one in the chain */
+    /* This iterator iterates one step ahead: cur is current iterated element, but is actually next in the chain */
     do {
       /* following steps: prev=last, host=next, next=cur */
       cur = (char**)xbt_dynar_iterator_next(bc->it);
     do {
       /* following steps: prev=last, host=next, next=cur */
       cur = (char**)xbt_dynar_iterator_next(bc->it);
@@ -49,8 +47,8 @@ int broadcaster_build_chain(broadcaster_t bc)
         next = *cur;
       else
         next = NULL;
         next = *cur;
       else
         next = NULL;
-      XBT_DEBUG("Building chain -- broadcaster:\"%s\" dest:\"%s\" prev:\"%s\" next:\"%s\"", me, current_host, prev, next);
-    
+      XBT_DEBUG("Building chain--broadcaster:\"%s\" dest:\"%s\" prev:\"%s\" next:\"%s\"", me, current_host, prev, next);
+
       /* Send message to current peer */
       task = task_message_chain_new(prev, next, bc->piece_count);
       MSG_task_send(task, current_host);
       /* Send message to current peer */
       task = task_message_chain_new(prev, next, bc->piece_count);
       MSG_task_send(task, current_host);
index c1f9198..e9aca94 100644 (file)
@@ -4,16 +4,10 @@
 /* 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. */
 
 /* 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. */
 
-#ifndef KADEPLOY_BROADCASTER_H
-#define KADEPLOY_BROADCASTER_H
-
-#include "simgrid/msg.h"
-#include "xbt/sysdep.h"
-
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
+#ifndef BROADCASTER_H
+#define BROADCASTER_H
 
 
+#include "xbt/dynar.h"
 #include "messages.h"
 #include "iterator.h"
 #include "common.h"
 #include "messages.h"
 #include "iterator.h"
 #include "common.h"
@@ -46,4 +40,4 @@ int broadcaster_send_file(broadcaster_t bc);
 /* Tasks */
 int broadcaster(int argc, char *argv[]);
 
 /* Tasks */
 int broadcaster(int argc, char *argv[]);
 
-#endif /* KADEPLOY_BROADCASTER_H */
+#endif /* BROADCASTER_H */
index 51ca4d7..e7316ac 100644 (file)
@@ -4,16 +4,7 @@
 /* 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. */
 
 /* 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 <stdlib.h>
-
-#include "simgrid/msg.h"        /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
-#include "xbt/sysdep.h"         /* calloc */
-
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-
+#include "simgrid/msg.h"
 #include "iterator.h"
 #include "messages.h"
 #include "broadcaster.h"
 #include "iterator.h"
 #include "messages.h"
 #include "broadcaster.h"
 
 /** @addtogroup MSG_examples
  * 
 
 /** @addtogroup MSG_examples
  * 
- *  - <b>chainsend/chainsend.c: Chainsend implementation</b>.
+ *  - <b>chainsend: MSG implementation of a file broadcasting system, similar to Kastafior (from Kadeploy).</b>.
  */
 
  */
 
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chainsend, "Messages specific for chainsend");
 
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chainsend,
-                             "Messages specific for chainsend");
-
-/*
- Data structures
- */
-
-/* Initialization stuff */
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file);
-
-
-/** Test function */
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file)
+int main(int argc, char *argv[])
 {
 {
-
   msg_error_t res = MSG_OK;
 
   msg_error_t res = MSG_OK;
 
-  XBT_DEBUG("test_all");
+  MSG_init(&argc, argv);
 
 
-  /*  Simulation setting */
-  MSG_create_environment(platform_file);
+  MSG_create_environment(argv[1]);
 
   /* Trace categories */
   TRACE_category_with_color("host0", "0 0 1");
 
   /* Trace categories */
   TRACE_category_with_color("host0", "0 0 1");
@@ -64,33 +40,11 @@ msg_error_t test_all(const char *platform_file,
   MSG_function_register("broadcaster", broadcaster);
   MSG_function_register("peer", peer);
 
   MSG_function_register("broadcaster", broadcaster);
   MSG_function_register("peer", peer);
 
-  MSG_launch_application(application_file);
+  MSG_launch_application(argv[2]);
 
   res = MSG_main();
 
 
   res = MSG_main();
 
-  return res;
-}                               /* end_of_test_all */
-
-
-/** Main function */
-int main(int argc, char *argv[])
-{
-  msg_error_t res = MSG_OK;
-
-#ifdef _MSC_VER
-  unsigned int prev_exponent_format =
-      _set_output_format(_TWO_DIGIT_EXPONENT);
-#endif
-
-  MSG_init(&argc, argv);
-
-  res = test_all(argv[1], argv[2]);
-
   XBT_INFO("Total simulation time: %e", MSG_get_clock());
 
   XBT_INFO("Total simulation time: %e", MSG_get_clock());
 
-#ifdef _MSC_VER
-  _set_output_format(prev_exponent_format);
-#endif
-
   return res != MSG_OK;
 }
   return res != MSG_OK;
 }
index 8b0249d..57ca331 100644 (file)
@@ -4,8 +4,8 @@
 /* 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. */
 
 /* 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. */
 
-#ifndef KADEPLOY_COMMON_H
-#define KADEPLOY_COMMON_H
+#ifndef COMMON_H
+#define COMMON_H
 
 #include "simgrid/msg.h"
 #include "xbt/sysdep.h"
 
 #include "simgrid/msg.h"
 #include "xbt/sysdep.h"
@@ -17,4 +17,4 @@ static XBT_INLINE void queue_pending_connection(msg_comm_t comm, xbt_dynar_t q)
 
 int process_pending_connections(xbt_dynar_t q);
 
 
 int process_pending_connections(xbt_dynar_t q);
 
-#endif /* KADEPLOY_COMMON_H */
+#endif /* COMMON_H */
index dfc2693..5d3d06d 100644 (file)
@@ -4,10 +4,8 @@
 /* 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. */
 
 /* 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. */
 
-#ifndef KADEPLOY_ITERATOR_H
-#define KADEPLOY_ITERATOR_H
-
-#include <stdlib.h>
+#ifndef ITERATOR_H
+#define ITERATOR_H
 
 #include "xbt/dynar.h"
 #include "xbt/sysdep.h"
 
 #include "xbt/dynar.h"
 #include "xbt/sysdep.h"
@@ -45,4 +43,4 @@ void xbt_dynar_shuffle_in_place(xbt_dynar_t indices_list);
     xbt_dynar_get_as(indices_list, (unsigned int)i, type)); \
   xbt_dynar_set_as(indices_list, (unsigned int)i, type, tmp);
 
     xbt_dynar_get_as(indices_list, (unsigned int)i, type)); \
   xbt_dynar_set_as(indices_list, (unsigned int)i, type, tmp);
 
-#endif /* KADEPLOY_ITERATOR_H */
+#endif /* ITERATOR_H */
index 9e976d4..e90bf62 100644 (file)
@@ -4,11 +4,10 @@
 /* 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. */
 
 /* 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. */
 
-#ifndef KADEPLOY_MESSAGES_H
-#define KADEPLOY_MESSAGES_H
+#ifndef MESSAGES_H
+#define MESSAGES_H
 
 #include "simgrid/msg.h"
 
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"
 
 #define MESSAGE_BUILD_CHAIN_SIZE 40
 #define MESSAGE_SEND_DATA_HEADER_SIZE 1
 
 #define MESSAGE_BUILD_CHAIN_SIZE 40
 #define MESSAGE_SEND_DATA_HEADER_SIZE 1
@@ -36,4 +35,4 @@ msg_task_t task_message_chain_new(const char* prev, const char *next, const unsi
 msg_task_t task_message_data_new(const char *block, unsigned int len);
 void task_message_delete(void *);
 
 msg_task_t task_message_data_new(const char *block, unsigned int len);
 void task_message_delete(void *);
 
-#endif /* KADEPLOY_MESSAGES_H */
+#endif /* MESSAGES_H */
index 6be29c1..433200e 100644 (file)
@@ -6,12 +6,7 @@
 
 #include "peer.h"
 
 
 #include "peer.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_peer,
-                             "Messages specific for the peer");
-
-/*******************************************************
- *                     Peer                            *
- *******************************************************/
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_peer, "Messages specific for the peer");
 
 void peer_init_chain(peer_t peer, message_t msg)
 {
 
 void peer_init_chain(peer_t peer, message_t msg)
 {
@@ -161,4 +156,4 @@ int peer(int argc, char *argv[])
   peer_delete(p);
 
   return status;
   peer_delete(p);
 
   return status;
-}                               /* end_of_receiver */
+}
index 71306b1..4ed5bcc 100644 (file)
@@ -4,11 +4,11 @@
 /* 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. */
 
 /* 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. */
 
-#ifndef KADEPLOY_PEER_H
-#define KADEPLOY_PEER_H
+#ifndef PEER_H
+#define PEER_H
 
 #include "simgrid/msg.h"
 
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"
+#include "xbt/dynar.h"
 
 #include "messages.h"
 #include "common.h"
 
 #include "messages.h"
 #include "common.h"
@@ -39,4 +39,4 @@ void peer_print_stats(peer_t p, float elapsed_time);
 
 int peer(int argc, char *argv[]);
 
 
 int peer(int argc, char *argv[]);
 
-#endif /* KADEPLOY_PEER_H */
+#endif /* PEER_H */
index ef8324c..800a648 100644 (file)
@@ -4,10 +4,7 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/asserts.h"
 #include "simgrid/modelchecker.h"
 #include <xbt/RngStream.h>
 #include "src/mc/mc_replay.h" // FIXME: this is an internal header
 #include "simgrid/modelchecker.h"
 #include <xbt/RngStream.h>
 #include "src/mc/mc_replay.h" // FIXME: this is an internal header
 /** @addtogroup MSG_examples
  *
  *  - <b>chord/chord.c: Classical Chord P2P protocol</b>
 /** @addtogroup MSG_examples
  *
  *  - <b>chord/chord.c: Classical Chord P2P protocol</b>
- *    This example implements the well known Chord P2P protocol. Its
- *    main advantage is that it constitute a fully working non-trivial
- *    example. In addition, its implementation is rather efficient, as
- *    demonstrated in http://hal.inria.fr/inria-00602216/
+ *    This example implements the well known Chord P2P protocol. Its main advantage is that it constitute a fully
+ *    working non-trivial example. In addition, its implementation is rather efficient, as demonstrated in
+ *    http://hal.inria.fr/inria-00602216/
  */
 
 
  */
 
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chord,
-                             "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chord, "Messages specific for this msg example");
 
 #define COMM_SIZE 10
 #define COMP_SIZE 0
 
 #define COMM_SIZE 10
 #define COMP_SIZE 0
@@ -42,17 +37,13 @@ static const double sleep_delay = 4.9999;
 
 extern long int smx_total_comms;
 
 
 extern long int smx_total_comms;
 
-/*
- * Finger element.
- */
+/* Finger element. */
 typedef struct s_finger {
   int id;
   char mailbox[MAILBOX_NAME_SIZE]; // string representation of the id
 } s_finger_t, *finger_t;
 
 typedef struct s_finger {
   int id;
   char mailbox[MAILBOX_NAME_SIZE]; // string representation of the id
 } s_finger_t, *finger_t;
 
-/*
- * Node data.
- */
+/* Node data. */
 typedef struct s_node {
   int id;                                 // my id
   char mailbox[MAILBOX_NAME_SIZE];        // my mailbox name (string representation of the id)
 typedef struct s_node {
   int id;                                 // my id
   char mailbox[MAILBOX_NAME_SIZE];        // my mailbox name (string representation of the id)
@@ -65,9 +56,7 @@ typedef struct s_node {
   RngStream stream;                       //RngStream for
 } s_node_t, *node_t;
 
   RngStream stream;                       //RngStream for
 } s_node_t, *node_t;
 
-/**
- * Types of tasks exchanged between nodes.
- */
+/* Types of tasks exchanged between nodes. */
 typedef enum {
   TASK_FIND_SUCCESSOR,
   TASK_FIND_SUCCESSOR_ANSWER,
 typedef enum {
   TASK_FIND_SUCCESSOR,
   TASK_FIND_SUCCESSOR_ANSWER,
@@ -80,9 +69,7 @@ typedef enum {
   TASK_PREDECESSOR_ALIVE_ANSWER
 } e_task_type_t;
 
   TASK_PREDECESSOR_ALIVE_ANSWER
 } e_task_type_t;
 
-/*
- * Data attached with the tasks sent and received
- */
+/* Data attached with the tasks sent and received */
 typedef struct s_task_data {
   e_task_type_t type;                     // type of task
   int request_id;                         // id paramater (used by some types of tasks)
 typedef struct s_task_data {
   e_task_type_t type;                     // type of task
   int request_id;                         // id paramater (used by some types of tasks)
@@ -96,7 +83,6 @@ static int *powers2;
 static xbt_dynar_t host_list;
 
 // utility functions
 static xbt_dynar_t host_list;
 
 // utility functions
-static void chord_initialize(void);
 static void chord_exit(void);
 static int normalize(int id);
 static int is_in_interval(int id, int start, int end);
 static void chord_exit(void);
 static int normalize(int id);
 static int is_in_interval(int id, int start, int end);
@@ -126,9 +112,7 @@ static void check_predecessor(node_t node);
 static void random_lookup(node_t);
 static void quit_notify(node_t node);
 
 static void random_lookup(node_t);
 static void quit_notify(node_t node);
 
-/**
- * \brief Global initialization of the Chord simulation.
- */
+/* \brief Global initialization of the Chord simulation. */
 static void chord_initialize(void)
 {
   // compute the powers of 2 once for all
 static void chord_initialize(void)
 {
   // compute the powers of 2 once for all
@@ -994,7 +978,8 @@ static void check_predecessor(node_t node)
           node->comm_receive = NULL;
           handle_task(node, task_received);
         }else{
           node->comm_receive = NULL;
           handle_task(node, task_received);
         }else{
-          XBT_DEBUG("Received the answer to my 'Predecessor Alive' request (task %p) : my predecessor %d is alive", task_received, node->pred_id);
+          XBT_DEBUG("Received the answer to my 'Predecessor Alive' request (task %p) : my predecessor %d is alive",
+                    task_received, node->pred_id);
           stop = 1;
           MSG_comm_destroy(node->comm_receive);
           node->comm_receive = NULL;
           stop = 1;
           MSG_comm_destroy(node->comm_receive);
           node->comm_receive = NULL;
@@ -1019,16 +1004,12 @@ static void random_lookup(node_t node)
 
 }
 
 
 }
 
-/**
- * \brief Main function.
- */
 int main(int argc, char *argv[])
 {
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, 
        "Usage: %s [-nb_bits=n] [-timeout=t] platform_file deployment_file\n"
 int main(int argc, char *argv[])
 {
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, 
        "Usage: %s [-nb_bits=n] [-timeout=t] platform_file deployment_file\n"
-       "\tExample: %s ../msg_platform.xml chord.xml\n", 
-       argv[0], argv[0]);
+       "\tExample: %s ../msg_platform.xml chord.xml\n", argv[0], argv[0]);
 
   char **options = &argv[1];
   while (!strncmp(options[0], "-", 1)) {
 
   char **options = &argv[1];
   while (!strncmp(options[0], "-", 1)) {
index 8e4209e..bd0bfc7 100644 (file)
@@ -4,15 +4,9 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"         /* calloc, printf */
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-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");
 
 #define MAXMBOXLEN 64
 
 
 #define MAXMBOXLEN 64
 
@@ -25,15 +19,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
 const double task_comp_size = 10000000;
 const double task_comm_size = 10000000;
 
 const double task_comp_size = 10000000;
 const double task_comm_size = 10000000;
 
-
-int master_fun(int argc, char *argv[]);
-int worker_fun(int argc, char *argv[]);
-
-
 static void send_tasks(int nb_workers)
 {
 static void send_tasks(int nb_workers)
 {
-  int i;
-  for (i = 0; i < nb_workers; i++) {
+  for (int i = 0; i < nb_workers; i++) {
     char *tname = bprintf("Task%02d", i);
     char *mbox  = bprintf("MBOX:WRK%02d", i);
 
     char *tname = bprintf("Task%02d", i);
     char *mbox  = bprintf("MBOX:WRK%02d", i);
 
@@ -47,7 +35,38 @@ static void send_tasks(int nb_workers)
   }
 }
 
   }
 }
 
-int master_fun(int argc, char *argv[])
+static int worker_fun(int argc, char *argv[])
+{
+  const char *pr_name = MSG_process_get_name(MSG_process_self());
+  char mbox[MAXMBOXLEN];
+  snprintf(mbox, MAXMBOXLEN, "MBOX:%s", pr_name);
+
+  XBT_INFO("%s is listening on mailbox(%s)", pr_name, mbox);
+
+  for (;;) {
+    msg_task_t task = NULL;
+
+    msg_error_t res = MSG_task_receive(&task, mbox);
+    if (res != MSG_OK) {
+      XBT_CRITICAL("MSG_task_get failed");
+      DIE_IMPOSSIBLE;
+    }
+
+    XBT_INFO("%s received task(%s) from mailbox(%s)", pr_name, MSG_task_get_name(task), mbox);
+
+    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+      MSG_task_destroy(task);
+      break;
+    }
+
+    MSG_task_execute(task);
+    XBT_INFO("%s executed task(%s)", pr_name, MSG_task_get_name(task));
+    MSG_task_destroy(task);
+  }
+  return 0;
+}
+
+static int master_fun(int argc, char *argv[])
 {
   msg_vm_t vm;
   unsigned int i;
 {
   msg_vm_t vm;
   unsigned int i;
@@ -57,11 +76,9 @@ int master_fun(int argc, char *argv[])
 
   xbt_dynar_t vms = xbt_dynar_new(sizeof(msg_vm_t), NULL);
 
 
   xbt_dynar_t vms = xbt_dynar_new(sizeof(msg_vm_t), NULL);
 
-
   /* Launch VMs and worker processes. One VM per PM, and one worker process per VM. */
   /* Launch VMs and worker processes. One VM per PM, and one worker process per VM. */
-
   XBT_INFO("# Launch %d VMs", nb_workers);
   XBT_INFO("# Launch %d VMs", nb_workers);
-  for (i = 0; i< nb_workers; i++) {
+  for (int i = 0; i< nb_workers; i++) {
     char *vm_name = bprintf("VM%02d", i);
     char *pr_name = bprintf("WRK%02d", i);
 
     char *vm_name = bprintf("VM%02d", i);
     char *pr_name = bprintf("WRK%02d", i);
 
@@ -85,7 +102,6 @@ int master_fun(int argc, char *argv[])
     xbt_free(pr_name);
   }
 
     xbt_free(pr_name);
   }
 
-
   /* Send a bunch of work to every one */
   XBT_INFO("# Send a task to %d worker process", nb_workers);
   send_tasks(nb_workers);
   /* Send a bunch of work to every one */
   XBT_INFO("# Send a task to %d worker process", nb_workers);
   send_tasks(nb_workers);
@@ -105,7 +121,6 @@ int master_fun(int argc, char *argv[])
     MSG_vm_resume(vm);
   }
 
     MSG_vm_resume(vm);
   }
 
-
   XBT_INFO("# Sleep long enough for everyone to be done with previous batch of work");
   MSG_process_sleep(1000 - MSG_get_clock());
 
   XBT_INFO("# Sleep long enough for everyone to be done with previous batch of work");
   MSG_process_sleep(1000 - MSG_get_clock());
 
@@ -138,7 +153,6 @@ int master_fun(int argc, char *argv[])
     MSG_vm_migrate(vm, worker_pm1);
   }
 
     MSG_vm_migrate(vm, worker_pm1);
   }
 
-
   XBT_INFO("# Shutdown the half of worker processes gracefuly. 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 gracefuly. The remaining half will be forcibly killed.");
   for (i = 0; i < nb_workers; i++) {
     char mbox[MAXMBOXLEN];
@@ -150,7 +164,6 @@ int master_fun(int argc, char *argv[])
   XBT_INFO("# Wait a while before effective shutdown.");
   MSG_process_sleep(2);
 
   XBT_INFO("# Wait a while before effective shutdown.");
   MSG_process_sleep(2);
 
-
   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 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));
@@ -161,56 +174,16 @@ int master_fun(int argc, char *argv[])
 
   XBT_INFO("# Goodbye now!");
   xbt_dynar_free(&vms);
 
   XBT_INFO("# Goodbye now!");
   xbt_dynar_free(&vms);
-
   return 0;
 }
 
 /** Receiver function  */
   return 0;
 }
 
 /** Receiver function  */
-int worker_fun(int argc, char *argv[])
-{
-  const char *pr_name = MSG_process_get_name(MSG_process_self());
-  char mbox[MAXMBOXLEN];
-  snprintf(mbox, MAXMBOXLEN, "MBOX:%s", pr_name);
-
-  XBT_INFO("%s is listenning on mailbox(%s)", pr_name, mbox);
-
-  for (;;) {
-    msg_task_t task = NULL;
-
-    msg_error_t res = MSG_task_receive(&task, mbox);
-    if (res != MSG_OK) {
-      XBT_CRITICAL("MSG_task_get failed");
-      DIE_IMPOSSIBLE;
-    }
-
-    XBT_INFO("%s received task(%s) from mailbox(%s)",
-        pr_name, MSG_task_get_name(task), mbox);
-
-    if (!strcmp(MSG_task_get_name(task), "finalize")) {
-      MSG_task_destroy(task);
-      break;
-    }
-
-    MSG_task_execute(task);
-    XBT_INFO("%s executed task(%s)", pr_name, MSG_task_get_name(task));
-    MSG_task_destroy(task);
-  }
-
-  return 0;
-}
-
-
-
-
 int main(int argc, char *argv[])
 {
   const int nb_workers = 2;
 
   MSG_init(&argc, argv);
 int main(int argc, char *argv[])
 {
   const int nb_workers = 2;
 
   MSG_init(&argc, argv);
-  if (argc != 2) {
-    printf("Usage: %s example/msg/msg_platform.xml\n", argv[0]);
-    return 1;
-  }
+  xbt_assert(argc >1,"Usage: %s example/msg/msg_platform.xml\n", argv[0]);
 
   /* Load the platform file */
   MSG_create_environment(argv[1]);
 
   /* Load the platform file */
   MSG_create_environment(argv[1]);
@@ -219,22 +192,17 @@ int main(int argc, char *argv[])
   xbt_dynar_t pms = MSG_hosts_as_dynar();
 
   /* we need a master node and worker nodes */
   xbt_dynar_t pms = MSG_hosts_as_dynar();
 
   /* we need a master node and worker nodes */
-  if (xbt_dynar_length(pms) < nb_workers + 1) {
-    XBT_CRITICAL("need %d hosts", nb_workers + 1);
-    return 1;
-  }
+  xbt_assert(xbt_dynar_length(pms) > nb_workers,"need %d hosts", nb_workers + 1);
 
   /* the first pm is the master, the others are workers */
   msg_host_t master_pm = xbt_dynar_get_as(pms, 0, msg_host_t);
 
   xbt_dynar_t worker_pms = xbt_dynar_new(sizeof(msg_host_t), NULL);
 
   /* the first pm is the master, the others are workers */
   msg_host_t master_pm = xbt_dynar_get_as(pms, 0, msg_host_t);
 
   xbt_dynar_t worker_pms = xbt_dynar_new(sizeof(msg_host_t), NULL);
-  int i;
-  for (i = 1; i < nb_workers + 1; i++) {
+  for (int i = 1; i < nb_workers + 1; i++) {
     msg_host_t pm = xbt_dynar_get_as(pms, i, msg_host_t);
     xbt_dynar_push(worker_pms, &pm);
   }
 
     msg_host_t pm = xbt_dynar_get_as(pms, i, msg_host_t);
     xbt_dynar_push(worker_pms, &pm);
   }
 
-
   /* Start the master process on the master pm. */
   MSG_process_create("master", master_fun, worker_pms, master_pm);
 
   /* Start the master process on the master pm. */
   MSG_process_create("master", master_fun, worker_pms, master_pm);
 
index 3d01d42..66ee458 100644 (file)
@@ -7,11 +7,11 @@ $ $SG_TEST_EXENV ${bindir:=.}/master_worker_vm$EXEEXT --log=no_loc ${srcdir:=.}/
 > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] create VM00 on PM(Intel)
 > [0.000000] [surf_vm/INFO] Create VM(VM00)@PM(Intel) with 0 mounted disks
 > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] put a process (WRK00) on VM00
 > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] create VM00 on PM(Intel)
 > [0.000000] [surf_vm/INFO] Create VM(VM00)@PM(Intel) with 0 mounted disks
 > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] put a process (WRK00) on VM00
-> [VM00:WRK00:(2) 0.000000] [msg_test/INFO] WRK00 is listenning on mailbox(MBOX:WRK00)
+> [VM00:WRK00:(2) 0.000000] [msg_test/INFO] WRK00 is listening on mailbox(MBOX:WRK00)
 > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] create VM01 on PM(Provost)
 > [0.000000] [surf_vm/INFO] Create VM(VM01)@PM(Provost) with 0 mounted disks
 > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] put a process (WRK01) on VM01
 > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] create VM01 on PM(Provost)
 > [0.000000] [surf_vm/INFO] Create VM(VM01)@PM(Provost) with 0 mounted disks
 > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] put a process (WRK01) on VM01
-> [VM01:WRK01:(3) 0.000000] [msg_test/INFO] WRK01 is listenning on mailbox(MBOX:WRK01)
+> [VM01:WRK01:(3) 0.000000] [msg_test/INFO] WRK01 is listening on mailbox(MBOX:WRK01)
 > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] # Send a task to 2 worker process
 > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] Send task(Task00) to mailbox(MBOX:WRK00)
 > [VM00:WRK00:(2) 23.846402] [msg_test/INFO] WRK00 received task(Task00) from mailbox(MBOX:WRK00)
 > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] # Send a task to 2 worker process
 > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] Send task(Task00) to mailbox(MBOX:WRK00)
 > [VM00:WRK00:(2) 23.846402] [msg_test/INFO] WRK00 received task(Task00) from mailbox(MBOX:WRK00)
@@ -27,9 +27,9 @@ $ $SG_TEST_EXENV ${bindir:=.}/master_worker_vm$EXEEXT --log=no_loc ${srcdir:=.}/
 > [VM01:WRK01:(3) 50.726576] [msg_test/INFO] WRK01 executed task(Task01)
 > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] # Add one more process on each VM
 > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] put a process (WRK02) on VM00
 > [VM01:WRK01:(3) 50.726576] [msg_test/INFO] WRK01 executed task(Task01)
 > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] # Add one more process on each VM
 > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] put a process (WRK02) on VM00
-> [VM00:WRK02:(4) 1000.000000] [msg_test/INFO] WRK02 is listenning on mailbox(MBOX:WRK02)
+> [VM00:WRK02:(4) 1000.000000] [msg_test/INFO] WRK02 is listening on mailbox(MBOX:WRK02)
 > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] put a process (WRK03) on VM01
 > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] put a process (WRK03) on VM01
-> [VM01:WRK03:(5) 1000.000000] [msg_test/INFO] WRK03 is listenning on mailbox(MBOX:WRK03)
+> [VM01:WRK03:(5) 1000.000000] [msg_test/INFO] WRK03 is listening on mailbox(MBOX:WRK03)
 > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] # Send a task to 4 worker process
 > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] Send task(Task00) to mailbox(MBOX:WRK00)
 > [VM00:WRK00:(2) 1023.846402] [msg_test/INFO] WRK00 received task(Task00) from mailbox(MBOX:WRK00)
 > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] # Send a task to 4 worker process
 > [Jacquelin:master:(1) 1000.000000] [msg_test/INFO] Send task(Task00) to mailbox(MBOX:WRK00)
 > [VM00:WRK00:(2) 1023.846402] [msg_test/INFO] WRK00 received task(Task00) from mailbox(MBOX:WRK00)
index 3eaed07..1c92fb5 100644 (file)
@@ -4,16 +4,9 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"         /* calloc, printf */
-
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-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");
 
 static void vm_migrate(msg_vm_t vm, msg_host_t dst_pm)
 {
 
 static void vm_migrate(msg_vm_t vm, msg_host_t dst_pm)
 {
@@ -67,8 +60,6 @@ static int master_main(int argc, char *argv[])
   s_vm_params_t params;
   memset(&params, 0, sizeof(params));
 
   s_vm_params_t params;
   memset(&params, 0, sizeof(params));
 
-
-
   vm0 = MSG_vm_create_core(pm0, "VM0");
   params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
   MSG_host_set_params(vm0, &params);
   vm0 = MSG_vm_create_core(pm0, "VM0");
   params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
   MSG_host_set_params(vm0, &params);
@@ -79,8 +70,6 @@ static int master_main(int argc, char *argv[])
 
   MSG_vm_destroy(vm0);
 
 
   MSG_vm_destroy(vm0);
 
-
-
   vm0 = MSG_vm_create_core(pm0, "VM0");
   params.ramsize = 1L * 1000 * 1000 * 100; // 100Mbytes
   MSG_host_set_params(vm0, &params);
   vm0 = MSG_vm_create_core(pm0, "VM0");
   params.ramsize = 1L * 1000 * 1000 * 100; // 100Mbytes
   MSG_host_set_params(vm0, &params);
@@ -91,8 +80,6 @@ static int master_main(int argc, char *argv[])
 
   MSG_vm_destroy(vm0);
 
 
   MSG_vm_destroy(vm0);
 
-
-
   vm0 = MSG_vm_create_core(pm0, "VM0");
   vm1 = MSG_vm_create_core(pm0, "VM1");
 
   vm0 = MSG_vm_create_core(pm0, "VM0");
   vm1 = MSG_vm_create_core(pm0, "VM1");
 
@@ -110,8 +97,6 @@ static int master_main(int argc, char *argv[])
   MSG_vm_destroy(vm0);
   MSG_vm_destroy(vm1);
 
   MSG_vm_destroy(vm0);
   MSG_vm_destroy(vm1);
 
-
-
   vm0 = MSG_vm_create_core(pm0, "VM0");
   vm1 = MSG_vm_create_core(pm0, "VM1");
 
   vm0 = MSG_vm_create_core(pm0, "VM0");
   vm1 = MSG_vm_create_core(pm0, "VM1");
 
@@ -129,7 +114,6 @@ static int master_main(int argc, char *argv[])
   MSG_vm_destroy(vm0);
   MSG_vm_destroy(vm1);
 
   MSG_vm_destroy(vm0);
   MSG_vm_destroy(vm1);
 
-
   return 0;
 }
 
   return 0;
 }
 
@@ -143,7 +127,6 @@ static void launch_master(msg_host_t host)
   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);
 }
 
-
 int main(int argc, char *argv[])
 {
   /* Get the arguments */
 int main(int argc, char *argv[])
 {
   /* Get the arguments */
@@ -159,6 +142,5 @@ int main(int argc, char *argv[])
   int res = MSG_main();
   XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
 
   int res = MSG_main();
   XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
 
-
   return !(res == MSG_OK);
 }
   return !(res == MSG_OK);
 }
index c6bd09f..32229cf 100644 (file)
@@ -4,19 +4,9 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"         /* calloc, printf */
-
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
 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");
 
-
-
-
-
 static int worker_main(int argc, char *argv[])
 {
   msg_task_t task = MSG_process_get_data(MSG_process_self());
 static int worker_main(int argc, char *argv[])
 {
   msg_task_t task = MSG_process_get_data(MSG_process_self());
@@ -27,21 +17,18 @@ static int worker_main(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
-
 struct task_data {
   msg_task_t task;
   double prev_computation_amount;
   double prev_clock;
 };
 
 struct task_data {
   msg_task_t task;
   double prev_computation_amount;
   double prev_clock;
 };
 
-
 static void task_data_init_clock(struct task_data *t)
 {
   t->prev_computation_amount = MSG_task_get_flops_amount(t->task);
   t->prev_clock = MSG_get_clock();
 }
 
 static void task_data_init_clock(struct task_data *t)
 {
   t->prev_computation_amount = MSG_task_get_flops_amount(t->task);
   t->prev_clock = MSG_get_clock();
 }
 
-
 static void task_data_get_clock(struct task_data *t)
 {
   double now_computation_amount = MSG_task_get_flops_amount(t->task);
 static void task_data_get_clock(struct task_data *t)
 {
   double now_computation_amount = MSG_task_get_flops_amount(t->task);
@@ -56,7 +43,6 @@ static void task_data_get_clock(struct task_data *t)
   t->prev_clock = now_clock;
 }
 
   t->prev_clock = now_clock;
 }
 
-
 static void test_pm_pin(void)
 {
   xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
 static void test_pm_pin(void)
 {
   xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
@@ -64,7 +50,6 @@ static void test_pm_pin(void)
   msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t);
   msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t);
 
   msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t);
   msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t);
 
-
   struct task_data t1;
   struct task_data t2;
   struct task_data t3;
   struct task_data t1;
   struct task_data t2;
   struct task_data t3;
@@ -80,7 +65,6 @@ static void test_pm_pin(void)
   MSG_process_create("worker3", worker_main, t3.task, pm1);
   MSG_process_create("worker4", worker_main, t4.task, pm1);
 
   MSG_process_create("worker3", worker_main, t3.task, pm1);
   MSG_process_create("worker4", worker_main, t4.task, pm1);
 
-
   XBT_INFO("## 1. start 4 tasks on PM1 (2 cores)");
   task_data_init_clock(&t1);
   task_data_init_clock(&t2);
   XBT_INFO("## 1. start 4 tasks on PM1 (2 cores)");
   task_data_init_clock(&t1);
   task_data_init_clock(&t2);
@@ -93,7 +77,6 @@ static void test_pm_pin(void)
   task_data_get_clock(&t3);
   task_data_get_clock(&t4);
 
   task_data_get_clock(&t3);
   task_data_get_clock(&t4);
 
-
   XBT_INFO("## 2. pin all tasks to CPU0");
   MSG_task_set_affinity(t1.task, pm1, 0x01);
   MSG_task_set_affinity(t2.task, pm1, 0x01);
   XBT_INFO("## 2. pin all tasks to CPU0");
   MSG_task_set_affinity(t1.task, pm1, 0x01);
   MSG_task_set_affinity(t2.task, pm1, 0x01);
@@ -106,7 +89,6 @@ static void test_pm_pin(void)
   task_data_get_clock(&t3);
   task_data_get_clock(&t4);
 
   task_data_get_clock(&t3);
   task_data_get_clock(&t4);
 
-
   XBT_INFO("## 3. clear the affinity of task4");
   MSG_task_set_affinity(t4.task, pm1, 0);
 
   XBT_INFO("## 3. clear the affinity of task4");
   MSG_task_set_affinity(t4.task, pm1, 0);
 
@@ -116,7 +98,6 @@ static void test_pm_pin(void)
   task_data_get_clock(&t3);
   task_data_get_clock(&t4);
 
   task_data_get_clock(&t3);
   task_data_get_clock(&t4);
 
-
   XBT_INFO("## 4. clear the affinity of task3");
   MSG_task_set_affinity(t3.task, pm1, 0);
 
   XBT_INFO("## 4. clear the affinity of task3");
   MSG_task_set_affinity(t3.task, pm1, 0);
 
@@ -126,7 +107,6 @@ static void test_pm_pin(void)
   task_data_get_clock(&t3);
   task_data_get_clock(&t4);
 
   task_data_get_clock(&t3);
   task_data_get_clock(&t4);
 
-
   XBT_INFO("## 5. clear the affinity of task2");
   MSG_task_set_affinity(t2.task, pm1, 0);
 
   XBT_INFO("## 5. clear the affinity of task2");
   MSG_task_set_affinity(t2.task, pm1, 0);
 
@@ -136,7 +116,6 @@ static void test_pm_pin(void)
   task_data_get_clock(&t3);
   task_data_get_clock(&t4);
 
   task_data_get_clock(&t3);
   task_data_get_clock(&t4);
 
-
   XBT_INFO("## 6. pin all tasks to CPU0 of another PM (no effect now)");
   MSG_task_set_affinity(t1.task, pm0, 0);
   MSG_task_set_affinity(t2.task, pm0, 0);
   XBT_INFO("## 6. pin all tasks to CPU0 of another PM (no effect now)");
   MSG_task_set_affinity(t1.task, pm0, 0);
   MSG_task_set_affinity(t2.task, pm0, 0);
@@ -149,8 +128,6 @@ static void test_pm_pin(void)
   task_data_get_clock(&t3);
   task_data_get_clock(&t4);
 
   task_data_get_clock(&t3);
   task_data_get_clock(&t4);
 
-
-
   MSG_task_cancel(t1.task);
   MSG_task_cancel(t2.task);
   MSG_task_cancel(t3.task);
   MSG_task_cancel(t1.task);
   MSG_task_cancel(t2.task);
   MSG_task_cancel(t3.task);
@@ -162,7 +139,6 @@ static void test_pm_pin(void)
   MSG_task_destroy(t4.task);
 }
 
   MSG_task_destroy(t4.task);
 }
 
-
 static void test_vm_pin(void)
 {
   xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
 static void test_vm_pin(void)
 {
   xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
@@ -170,7 +146,6 @@ static void test_vm_pin(void)
   msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t); // 2 cores
   msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t); // 4 cores
 
   msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t); // 2 cores
   msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t); // 4 cores
 
-
   /* set up VMs on PM2 (4 cores) */
   msg_vm_t vm0 = MSG_vm_create_core(pm2, "VM0");
   msg_vm_t vm1 = MSG_vm_create_core(pm2, "VM1");
   /* set up VMs on PM2 (4 cores) */
   msg_vm_t vm0 = MSG_vm_create_core(pm2, "VM0");
   msg_vm_t vm1 = MSG_vm_create_core(pm2, "VM1");
@@ -193,7 +168,6 @@ static void test_vm_pin(void)
   MSG_vm_start(vm2);
   MSG_vm_start(vm3);
 
   MSG_vm_start(vm2);
   MSG_vm_start(vm3);
 
-
   /* set up tasks and processes */
   struct task_data t0;
   struct task_data t1;
   /* set up tasks and processes */
   struct task_data t0;
   struct task_data t1;
@@ -210,7 +184,6 @@ static void test_vm_pin(void)
   MSG_process_create("worker2", worker_main, t2.task, vm2);
   MSG_process_create("worker3", worker_main, t3.task, vm3);
 
   MSG_process_create("worker2", worker_main, t2.task, vm2);
   MSG_process_create("worker3", worker_main, t3.task, vm3);
 
-
   /* start experiments */
   XBT_INFO("## 1. start 4 VMs on PM2 (4 cores)");
   task_data_init_clock(&t0);
   /* start experiments */
   XBT_INFO("## 1. start 4 VMs on PM2 (4 cores)");
   task_data_init_clock(&t0);
@@ -224,7 +197,6 @@ static void test_vm_pin(void)
   task_data_get_clock(&t2);
   task_data_get_clock(&t3);
 
   task_data_get_clock(&t2);
   task_data_get_clock(&t3);
 
-
   XBT_INFO("## 2. pin all VMs to CPU0 of PM2");
   MSG_vm_set_affinity(vm0, pm2, 0x01);
   MSG_vm_set_affinity(vm1, pm2, 0x01);
   XBT_INFO("## 2. pin all VMs to CPU0 of PM2");
   MSG_vm_set_affinity(vm0, pm2, 0x01);
   MSG_vm_set_affinity(vm1, pm2, 0x01);
@@ -237,7 +209,6 @@ static void test_vm_pin(void)
   task_data_get_clock(&t2);
   task_data_get_clock(&t3);
 
   task_data_get_clock(&t2);
   task_data_get_clock(&t3);
 
-
   XBT_INFO("## 3. pin all VMs to CPU0 of PM1 (no effect at now)");
   /* Because VMs are on PM2, the below operations do not effect computation now. */
   MSG_vm_set_affinity(vm0, pm1, 0x01);
   XBT_INFO("## 3. pin all VMs to CPU0 of PM1 (no effect at now)");
   /* Because VMs are on PM2, the below operations do not effect computation now. */
   MSG_vm_set_affinity(vm0, pm1, 0x01);
@@ -251,7 +222,6 @@ static void test_vm_pin(void)
   task_data_get_clock(&t2);
   task_data_get_clock(&t3);
 
   task_data_get_clock(&t2);
   task_data_get_clock(&t3);
 
-
   XBT_INFO("## 4. unpin VM0, and pin VM2 and VM3 to CPU1 of PM2");
   MSG_vm_set_affinity(vm0, pm2, 0x00);
   MSG_vm_set_affinity(vm2, pm2, 0x02);
   XBT_INFO("## 4. unpin VM0, and pin VM2 and VM3 to CPU1 of PM2");
   MSG_vm_set_affinity(vm0, pm2, 0x00);
   MSG_vm_set_affinity(vm2, pm2, 0x02);
@@ -263,7 +233,6 @@ static void test_vm_pin(void)
   task_data_get_clock(&t2);
   task_data_get_clock(&t3);
 
   task_data_get_clock(&t2);
   task_data_get_clock(&t3);
 
-
   XBT_INFO("## 5. migrate all VMs to PM0 (only 1 CPU core)");
   MSG_vm_migrate(vm0, pm0);
   MSG_vm_migrate(vm1, pm0);
   XBT_INFO("## 5. migrate all VMs to PM0 (only 1 CPU core)");
   MSG_vm_migrate(vm0, pm0);
   MSG_vm_migrate(vm1, pm0);
@@ -282,7 +251,6 @@ static void test_vm_pin(void)
   task_data_get_clock(&t2);
   task_data_get_clock(&t3);
 
   task_data_get_clock(&t2);
   task_data_get_clock(&t3);
 
-
   XBT_INFO("## 6. migrate all VMs to PM1 (2 CPU cores, with affinity settings)");
   MSG_vm_migrate(vm0, pm1);
   MSG_vm_migrate(vm1, pm1);
   XBT_INFO("## 6. migrate all VMs to PM1 (2 CPU cores, with affinity settings)");
   MSG_vm_migrate(vm0, pm1);
   MSG_vm_migrate(vm1, pm1);
@@ -320,7 +288,6 @@ static void test_vm_pin(void)
   task_data_get_clock(&t2);
   task_data_get_clock(&t3);
 
   task_data_get_clock(&t2);
   task_data_get_clock(&t3);
 
-
   /* clean up everything */
   MSG_task_cancel(t0.task);
   MSG_task_cancel(t1.task);
   /* clean up everything */
   MSG_task_cancel(t0.task);
   MSG_task_cancel(t1.task);
@@ -338,7 +305,6 @@ static void test_vm_pin(void)
   MSG_vm_destroy(vm3);
 }
 
   MSG_vm_destroy(vm3);
 }
 
-
 static int master_main(int argc, char *argv[])
 {
   XBT_INFO("=== Test PM (set affinity) ===");
 static int master_main(int argc, char *argv[])
 {
   XBT_INFO("=== Test PM (set affinity) ===");
@@ -350,7 +316,6 @@ static int master_main(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
-
 int main(int argc, char *argv[])
 {
   /* Get the arguments */
 int main(int argc, char *argv[])
 {
   /* Get the arguments */
@@ -369,21 +334,17 @@ int main(int argc, char *argv[])
   msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t);
   msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t);
 
   msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t);
   msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t);
 
-
-  XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm0), MSG_host_get_core_number(pm0), MSG_get_host_speed(pm0));
-  XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm1), MSG_host_get_core_number(pm1), MSG_get_host_speed(pm1));
-  XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm2), MSG_host_get_core_number(pm2), MSG_get_host_speed(pm2));
-
-
+  XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm0), MSG_host_get_core_number(pm0),
+           MSG_get_host_speed(pm0));
+  XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm1), MSG_host_get_core_number(pm1),
+           MSG_get_host_speed(pm1));
+  XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm2), MSG_host_get_core_number(pm2),
+           MSG_get_host_speed(pm2));
 
   MSG_process_create("master", master_main, NULL, pm0);
 
 
   MSG_process_create("master", master_main, NULL, pm0);
 
-
-
-
   int res = MSG_main();
   XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
 
   int res = MSG_main();
   XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
 
-
   return !(res == MSG_OK);
 }
   return !(res == MSG_OK);
 }
index 1c45b8c..9cc1153 100644 (file)
@@ -4,16 +4,10 @@
 /* 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. */
 
 /* 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 <sys/time.h>
 #include "simgrid/msg.h"
 #include <sys/time.h>
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"         /* calloc, printf */
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-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");
 
 /*
  * Usage:
 
 /*
  * Usage:
@@ -26,12 +20,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
 static double time_precise(void) {
   struct timeval tv;
   int ret = gettimeofday(&tv, NULL);
 static double time_precise(void) {
   struct timeval tv;
   int ret = gettimeofday(&tv, NULL);
-  if (ret < 0)
-    xbt_die("gettimeofday");
-
-  double now = (double) tv.tv_sec + tv.tv_usec * 0.001 * 0.001;
-
-  return now;
+  xbt_assert(ret >= 0, "gettimeofday");
+  return (double) tv.tv_sec + tv.tv_usec * 0.001 * 0.001;
 }
 
 static int computation_fun(int argc, char *argv[]) {
 }
 
 static int computation_fun(int argc, char *argv[]) {
@@ -46,8 +36,6 @@ static int computation_fun(int argc, char *argv[]) {
 
     // XBT_INFO("%f", clock_end - clock_sta);
   }
 
     // XBT_INFO("%f", clock_end - clock_sta);
   }
-
-
   return 0;
 }
 
   return 0;
 }
 
@@ -81,7 +69,6 @@ static int master_main(int argc, char *argv[])
     xbt_free(vm_name);
   }
 
     xbt_free(vm_name);
   }
 
-
   XBT_INFO("## Test (start)");
 
   for (i = 0; i < 10; i++) {
   XBT_INFO("## Test (start)");
 
   for (i = 0; i < 10; i++) {
@@ -91,13 +78,11 @@ static int master_main(int argc, char *argv[])
     XBT_INFO("duration %f", clock_end - clock_sta);
   }
 
     XBT_INFO("duration %f", clock_end - clock_sta);
   }
 
-
   for (i = 0; i < nvm; i++) {
     MSG_vm_destroy(vm[i]);
   }
 
   XBT_INFO("## Test (ended)");
   for (i = 0; i < nvm; i++) {
     MSG_vm_destroy(vm[i]);
   }
 
   XBT_INFO("## Test (ended)");
-  
   return 0;
 }
 
   return 0;
 }
 
@@ -128,6 +113,5 @@ int main(int argc, char *argv[])
   int res = MSG_main();
   XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
 
   int res = MSG_main();
   XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
 
-
   return !(res == MSG_OK);
 }
   return !(res == MSG_OK);
 }
index aac646c..4140f38 100644 (file)
@@ -4,16 +4,8 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"         /* calloc, printf */
-
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-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");
 
 static int computation_fun(int argc, char *argv[])
 {
 
 static int computation_fun(int argc, char *argv[])
 {
@@ -81,9 +73,7 @@ static int communication_rx_fun(int argc, char *argv[])
   struct task_priv *priv = MSG_task_get_data(task);
   double clock_end = MSG_get_clock();
 
   struct task_priv *priv = MSG_task_get_data(task);
   double clock_end = MSG_get_clock();
 
-  XBT_INFO("%s:%s to %s:%s => %g sec",
-      MSG_host_get_name(priv->tx_host),
-      MSG_process_get_name(priv->tx_proc),
+  XBT_INFO("%s:%s to %s:%s => %g sec", MSG_host_get_name(priv->tx_host), MSG_process_get_name(priv->tx_proc),
       host_name, pr_name, clock_end - priv->clock_sta);
 
   xbt_free(priv);
       host_name, pr_name, clock_end - priv->clock_sta);
 
   xbt_free(priv);
@@ -94,9 +84,7 @@ static int communication_rx_fun(int argc, char *argv[])
 
 static 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 *mbox = bprintf("MBOX:%s-%s", MSG_host_get_name(tx_host), MSG_host_get_name(rx_host));
   char **argv = NULL;
   
   const char *pr_name_tx =  "comm_tx";
   char **argv = NULL;
   
   const char *pr_name_tx =  "comm_tx";
@@ -146,7 +134,6 @@ static int master_main(int argc, char *argv[])
 
   XBT_INFO("## Test 1 (ended)");
 
 
   XBT_INFO("## Test 1 (ended)");
 
-
   XBT_INFO("## Test 2 (started): check impact of running a task inside a VM (there is no degradation for the moment)");
 
   XBT_INFO("### Put a VM on a PM, and put a task to the VM");
   XBT_INFO("## Test 2 (started): check impact of running a task inside a VM (there is no degradation for the moment)");
 
   XBT_INFO("### Put a VM on a PM, and put a task to the VM");
@@ -158,7 +145,6 @@ static int master_main(int argc, char *argv[])
 
   XBT_INFO("## Test 2 (ended)");
 
 
   XBT_INFO("## Test 2 (ended)");
 
-  
   XBT_INFO("## Test 3 (started): check impact of running a task collocated with a VM (there is no VM noise for the moment)");
 
   XBT_INFO("### Put a VM on a PM, and put a task to the PM");
   XBT_INFO("## Test 3 (started): check impact of running a task collocated with a VM (there is no VM noise for the moment)");
 
   XBT_INFO("### Put a VM on a PM, and put a task to the PM");
@@ -170,8 +156,8 @@ static int master_main(int argc, char *argv[])
 
   XBT_INFO("## Test 3 (ended)");
 
 
   XBT_INFO("## Test 3 (ended)");
 
-
-  XBT_INFO("## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1");
+  XBT_INFO("## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for"
+           " the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1");
 
   XBT_INFO("### Put two VMs on a PM, and put a task to each VM");
   vm0 = MSG_vm_create_core(pm0, "VM0");
 
   XBT_INFO("### Put two VMs on a PM, and put a task to each VM");
   vm0 = MSG_vm_create_core(pm0, "VM0");
@@ -196,7 +182,6 @@ static int master_main(int argc, char *argv[])
   MSG_vm_destroy(vm1);
   XBT_INFO("## Test 4 (ended)");
 
   MSG_vm_destroy(vm1);
   XBT_INFO("## Test 4 (ended)");
 
-  
   XBT_INFO("## Test 5  (started): Analyse network impact");
   XBT_INFO("### Make a connection between PM0 and PM1");
   launch_communication_worker(pm0, pm1);
   XBT_INFO("## Test 5  (started): Analyse network impact");
   XBT_INFO("### Make a connection between PM0 and PM1");
   launch_communication_worker(pm0, pm1);
@@ -250,8 +235,8 @@ static int master_main(int argc, char *argv[])
 
   XBT_INFO("## Test 5 (ended)");
 
 
   XBT_INFO("## Test 5 (ended)");
 
-
-  XBT_INFO("## Test 6 (started): Check migration impact (not yet implemented neither on the CPU resource nor on the network one");
+  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("### Relocate VM0 between PM0 and PM1");
   vm0 = MSG_vm_create_core(pm0, "VM0");
   {
@@ -269,7 +254,7 @@ static int master_main(int argc, char *argv[])
   MSG_process_sleep(5);
   MSG_vm_destroy(vm0);
   XBT_INFO("## Test 6 (ended)");
   MSG_process_sleep(5);
   MSG_vm_destroy(vm0);
   XBT_INFO("## Test 6 (ended)");
-  
+
   xbt_dynar_free(&hosts_dynar);
   return 0;
 }
   xbt_dynar_free(&hosts_dynar);
   return 0;
 }
@@ -284,7 +269,6 @@ static void launch_master(msg_host_t host)
   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);
 }
 
-
 int main(int argc, char *argv[])
 {
   /* Get the arguments */
 int main(int argc, char *argv[])
 {
   /* Get the arguments */
index d2e8263..15c9698 100644 (file)
@@ -4,14 +4,9 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"
 
 
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-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");
 
 msg_task_t atask = NULL;
 
 
 msg_task_t atask = NULL;
 
@@ -108,6 +103,3 @@ int main(int argc, char *argv[]){
   return !(res == MSG_OK);
 }
 
   return !(res == MSG_OK);
 }
 
-
-
-
index 092515d..5e1bd00 100644 (file)
@@ -4,60 +4,42 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"
 
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"         /* calloc */
 #include "simgrid/plugins/energy.h"
 
 #include "simgrid/plugins/energy.h"
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
+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");
-
-int dvfs(int argc, char *argv[]);
-
-
-int dvfs(int argc, char *argv[])
+static int dvfs(int argc, char *argv[])
 {
 {
-  msg_host_t host = NULL;
-  msg_task_t task1 = NULL;
-  host = MSG_host_by_name("MyHost1");
+  msg_host_t host = MSG_host_by_name("MyHost1");
 
 
-
-  XBT_INFO("Energetic profile: %s",
-      MSG_host_get_property_value(host,"watt_per_state"));
-  XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J",
-      MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
+  XBT_INFO("Energetic profile: %s",MSG_host_get_property_value(host,"watt_per_state"));
+  XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", MSG_host_get_current_power_peak(host),
+           sg_host_get_consumed_energy(host));
 
   double start = MSG_get_clock();
   XBT_INFO("Sleep for 10 seconds");
   MSG_process_sleep(10);
 
   double start = MSG_get_clock();
   XBT_INFO("Sleep for 10 seconds");
   MSG_process_sleep(10);
-  XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J",
-      MSG_get_clock()-start,
+  XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J", MSG_get_clock()-start,
       MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
 
   // Run a task
   start = MSG_get_clock();
       MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
 
   // Run a task
   start = MSG_get_clock();
-  task1 = MSG_task_create ("t1", 100E6, 0, NULL);
+  msg_task_t task1 = MSG_task_create ("t1", 100E6, 0, NULL);
   XBT_INFO("Run a task of %.0E flops",MSG_task_get_flops_amount(task1));
   MSG_task_execute (task1);
   MSG_task_destroy(task1);
   XBT_INFO("Run a task of %.0E flops",MSG_task_get_flops_amount(task1));
   MSG_task_execute (task1);
   MSG_task_destroy(task1);
-  XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW depending on load; Energy dissipated=%.0f J",
-      MSG_get_clock()-start,
-      MSG_host_get_current_power_peak(host), sg_host_get_wattmin_at(host,MSG_host_get_pstate(host)),
-      sg_host_get_wattmax_at(host,MSG_host_get_pstate(host)),
-      sg_host_get_consumed_energy(host));
+  XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW"
+           " depending on load; Energy dissipated=%.0f J", MSG_get_clock()-start,
+           MSG_host_get_current_power_peak(host), sg_host_get_wattmin_at(host,MSG_host_get_pstate(host)),
+           sg_host_get_wattmax_at(host,MSG_host_get_pstate(host)), sg_host_get_consumed_energy(host));
 
   // ========= Change power peak =========
   int pstate=2;
   MSG_host_set_pstate(host, pstate);
   XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)",
 
   // ========= Change power peak =========
   int pstate=2;
   MSG_host_set_pstate(host, pstate);
   XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)",
-      pstate,
-      MSG_host_get_power_peak_at(host, pstate),
-      MSG_host_get_current_power_peak(host));
+      pstate, MSG_host_get_power_peak_at(host, pstate), MSG_host_get_current_power_peak(host));
 
   // Run a second task
   start = MSG_get_clock();
 
   // Run a second task
   start = MSG_get_clock();
@@ -66,15 +48,13 @@ int dvfs(int argc, char *argv[])
   MSG_task_execute (task1);
   MSG_task_destroy(task1);
   XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
   MSG_task_execute (task1);
   MSG_task_destroy(task1);
   XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
-      MSG_get_clock()-start,
-      MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
+      MSG_get_clock()-start, MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
 
   start = MSG_get_clock();
   XBT_INFO("Sleep for 4 seconds");
   MSG_process_sleep(4);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
 
   start = MSG_get_clock();
   XBT_INFO("Sleep for 4 seconds");
   MSG_process_sleep(4);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
-      MSG_get_clock()-start,
-      MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
+      MSG_get_clock()-start, MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
 
   // =========== Turn the other host off ==========
   XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated %.0f J so far.",
 
   // =========== Turn the other host off ==========
   XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated %.0f J so far.",
@@ -83,8 +63,7 @@ int dvfs(int argc, char *argv[])
   start = MSG_get_clock();
   MSG_process_sleep(10);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
   start = MSG_get_clock();
   MSG_process_sleep(10);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
-      MSG_get_clock()-start,
-      MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
+      MSG_get_clock()-start, MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
   return 0;
 }
 
   return 0;
 }
 
@@ -95,12 +74,9 @@ int main(int argc, char *argv[])
   MSG_init(&argc, argv);
 
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
   MSG_init(&argc, argv);
 
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-            "\tExample: %s msg_platform.xml msg_deployment.xml\n", 
-            argv[0], argv[0]);
-  MSG_create_environment(argv[1]);
+            "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
 
 
-  /*   Application deployment */
+  MSG_create_environment(argv[1]);
   MSG_function_register("dvfs_test", dvfs);
 
   MSG_launch_application(argv[2]);
   MSG_function_register("dvfs_test", dvfs);
 
   MSG_launch_application(argv[2]);
@@ -111,4 +87,3 @@ int main(int argc, char *argv[])
 
   return res != MSG_OK;
 }
 
   return res != MSG_OK;
 }
-
index 4f0b927..78ced0e 100644 (file)
@@ -4,21 +4,13 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"
 
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"         /* calloc */
 #include "simgrid/plugins/energy.h"
 
 #include "simgrid/plugins/energy.h"
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-
-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");
 
 static void simulate_bootup(msg_host_t host) {
 
 static void simulate_bootup(msg_host_t host) {
-
   int previous_pstate = MSG_host_get_pstate(host);
 
   XBT_INFO("Switch to virtual pstate 3, that encodes the shutting down state in the XML file of that example");
   int previous_pstate = MSG_host_get_pstate(host);
 
   XBT_INFO("Switch to virtual pstate 3, that encodes the shutting down state in the XML file of that example");
@@ -42,7 +34,6 @@ static void simulate_bootup(msg_host_t host) {
 }
 
 static void simulate_shutdown(msg_host_t host) {
 }
 
 static void simulate_shutdown(msg_host_t host) {
-
   int previous_pstate = MSG_host_get_pstate(host);
 
   XBT_INFO("Switch to virtual pstate 4, that encodes the shutting down state in the XML file of that example");
   int previous_pstate = MSG_host_get_pstate(host);
 
   XBT_INFO("Switch to virtual pstate 4, that encodes the shutting down state in the XML file of that example");
@@ -67,8 +58,7 @@ static void simulate_shutdown(msg_host_t host) {
 static int onoff(int argc, char *argv[]) {
   msg_host_t host1 = MSG_host_by_name("MyHost1");
 
 static int onoff(int argc, char *argv[]) {
   msg_host_t host1 = MSG_host_by_name("MyHost1");
 
-  XBT_INFO("Energetic profile: %s",
-     MSG_host_get_property_value(host1,"watt_per_state"));
+  XBT_INFO("Energetic profile: %s", MSG_host_get_property_value(host1,"watt_per_state"));
   XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J",
      MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
 
   XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J",
      MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
 
@@ -90,7 +80,6 @@ static int onoff(int argc, char *argv[]) {
   XBT_INFO("Host1 is now ON again. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
      MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
 
   XBT_INFO("Host1 is now ON again. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
      MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
 
-
   return 0;
 }
 
   return 0;
 }
 
@@ -101,14 +90,11 @@ int main(int argc, char *argv[])
   MSG_init(&argc, argv);
 
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
   MSG_init(&argc, argv);
 
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-       "\tExample: %s msg_platform.xml msg_deployment.xml\n", 
-       argv[0], argv[0]);
+       "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
 
   MSG_create_environment(argv[1]);
 
 
   MSG_create_environment(argv[1]);
 
-  /*   Application deployment */
   MSG_function_register("onoff_test", onoff);
   MSG_function_register("onoff_test", onoff);
-
   MSG_launch_application(argv[2]);
 
   res = MSG_main();
   MSG_launch_application(argv[2]);
 
   res = MSG_main();
@@ -117,4 +103,3 @@ int main(int argc, char *argv[])
 
   return res != MSG_OK;
 }
 
   return res != MSG_OK;
 }
-
index cd37f4d..817e1ea 100644 (file)
@@ -5,38 +5,21 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"         /* calloc */
-
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-
 
 /** @addtogroup MSG_examples
  *
 
 /** @addtogroup MSG_examples
  *
- * - <b>energy/e1/e1.c</b> Shows how a set of pstates can be defined
- *     for a host and how the current pstate can be accessed/changed
- *     with @ref MSG_get_host_current_power_peak and @ref
- *     MSG_set_host_pstate.
- *     Make sure to read the platform XML file for details on how
- *     to declare the CPU capacity for each pstate.
- *
+ * - <b>energy/e1/e1.c</b> Shows how a set of pstates can be defined for a host and how the current pstate can be
+ *     accessed/changed with @ref MSG_get_host_current_power_peak and @ref  MSG_set_host_pstate.
+ *     Make sure to read the platform XML file for details on how to declare the CPU capacity for each pstate.
  */
 
  */
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,
-                             "Pstate properties test");
-
-int dvfs(int argc, char *argv[]);
-
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Pstate properties test");
 
 
-int dvfs(int argc, char *argv[])
+static int dvfs(int argc, char *argv[])
 {
 {
-  msg_host_t host = NULL;
-  msg_task_t task1 = NULL;
-  double task_time = 0;
   double workload = 100E6;
   int new_peak_index=2;
   double workload = 100E6;
   int new_peak_index=2;
-  host = MSG_host_self();; //MSG_get_host_by_name("MyHost1");
+  msg_host_t host = MSG_host_self();; //MSG_get_host_by_name("MyHost1");
 
   int nb = MSG_host_get_nb_pstates(host);
   XBT_INFO("Count of Processor states=%d", nb);
 
   int nb = MSG_host_get_nb_pstates(host);
   XBT_INFO("Count of Processor states=%d", nb);
@@ -45,19 +28,18 @@ int dvfs(int argc, char *argv[])
   XBT_INFO("Current power peak=%f", current_peak);
 
   // Run a task
   XBT_INFO("Current power peak=%f", current_peak);
 
   // Run a task
-  task1 = MSG_task_create ("t1", workload, 0, NULL);
+  msg_task_t task1 = MSG_task_create ("t1", workload, 0, NULL);
   MSG_task_execute (task1);
   MSG_task_destroy(task1);
 
   MSG_task_execute (task1);
   MSG_task_destroy(task1);
 
-  task_time = MSG_get_clock();
+  double task_time = MSG_get_clock();
   XBT_INFO("Task1 simulation time: %e", task_time);
 
   // Change power peak
   XBT_INFO("Task1 simulation time: %e", task_time);
 
   // Change power peak
-  if ((new_peak_index >= nb) || (new_peak_index < 0))
-    {
+  if ((new_peak_index >= nb) || (new_peak_index < 0)){
     XBT_INFO("Cannot set pstate %d, host supports only %d pstates", new_peak_index, nb);
     return 0;
     XBT_INFO("Cannot set pstate %d, host supports only %d pstates", new_peak_index, nb);
     return 0;
-    }
+  }
 
   double peak_at = MSG_host_get_power_peak_at(host, new_peak_index);
   XBT_INFO("Changing power peak value to %f (at index %d)", peak_at, new_peak_index);
 
   double peak_at = MSG_host_get_power_peak_at(host, new_peak_index);
   XBT_INFO("Changing power peak value to %f (at index %d)", peak_at, new_peak_index);
@@ -75,7 +57,6 @@ int dvfs(int argc, char *argv[])
   task_time = MSG_get_clock() - task_time;
   XBT_INFO("Task2 simulation time: %e", task_time);
 
   task_time = MSG_get_clock() - task_time;
   XBT_INFO("Task2 simulation time: %e", task_time);
 
-
   // Verify the default pstate is set to 0
   host = MSG_host_by_name("MyHost2");
   int nb2 = MSG_host_get_nb_pstates(host);
   // Verify the default pstate is set to 0
   host = MSG_host_by_name("MyHost2");
   int nb2 = MSG_host_get_nb_pstates(host);
@@ -93,14 +74,11 @@ int main(int argc, char *argv[])
   MSG_init(&argc, argv);
 
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
   MSG_init(&argc, argv);
 
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-            "\tExample: %s msg_platform.xml msg_deployment.xml\n", 
-            argv[0], argv[0]);
-  
+            "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
+
   MSG_create_environment(argv[1]);
 
   MSG_create_environment(argv[1]);
 
-  /*   Application deployment */
   MSG_function_register("dvfs_test", dvfs);
   MSG_function_register("dvfs_test", dvfs);
-
   MSG_launch_application(argv[2]);
 
   res = MSG_main();
   MSG_launch_application(argv[2]);
 
   res = MSG_main();
@@ -109,4 +87,3 @@ int main(int argc, char *argv[])
 
   return res != MSG_OK;
 }
 
   return res != MSG_OK;
 }
-
index 982bc54..3959b1f 100644 (file)
@@ -5,10 +5,6 @@ set(tesh_files
   ${tesh_files}
   ${CMAKE_CURRENT_SOURCE_DIR}/energy_vm.tesh
   PARENT_SCOPE)
   ${tesh_files}
   ${CMAKE_CURRENT_SOURCE_DIR}/energy_vm.tesh
   PARENT_SCOPE)
-set(xml_files
-  ${xml_files}
-  ${CMAKE_CURRENT_SOURCE_DIR}/deployment_consumption.xml
-  PARENT_SCOPE)
 set(examples_src
   ${examples_src}
   ${CMAKE_CURRENT_SOURCE_DIR}/energy_vm.c
 set(examples_src
   ${examples_src}
   ${CMAKE_CURRENT_SOURCE_DIR}/energy_vm.c
diff --git a/examples/msg/energy/vm/deployment_consumption.xml b/examples/msg/energy/vm/deployment_consumption.xml
deleted file mode 100644 (file)
index 52ebe54..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
-<platform version="4">
-  <process host="MyHost1" function="dvfs_test" />
-</platform>
index 14a41d6..96175d3 100644 (file)
@@ -4,19 +4,12 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"
 
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"         /* calloc */
 #include "simgrid/plugins/energy.h"
 
 #include "simgrid/plugins/energy.h"
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-
 XBT_LOG_NEW_DEFAULT_CATEGORY(energy_vm, "Messages of this example");
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(energy_vm, "Messages of this example");
 
-
 static int worker_func() {
   msg_task_t task1 = MSG_task_create("t1", 300E6, 0, NULL);
   MSG_task_execute (task1);
 static int worker_func() {
   msg_task_t task1 = MSG_task_create("t1", 300E6, 0, NULL);
   MSG_task_execute (task1);
@@ -50,7 +43,8 @@ static int dvfs(int argc, char *argv[])
   MSG_process_create("p31", worker_func, NULL, vm_host3);
   MSG_process_create("p32", worker_func, NULL, vm_host3);
 
   MSG_process_create("p31", worker_func, NULL, vm_host3);
   MSG_process_create("p32", worker_func, NULL, vm_host3);
 
-  XBT_INFO("Wait 5 seconds. The tasks are still running (they run for 3 seconds, but 2 tasks are co-located, so they run for 6 seconds)");
+  XBT_INFO("Wait 5 seconds. The tasks are still running (they run for 3 seconds, but 2 tasks are co-located, "
+           "so they run for 6 seconds)");
   MSG_process_sleep(5);
   XBT_INFO("Wait another 5 seconds. The tasks stop at some point in between");
   MSG_process_sleep(5);
   MSG_process_sleep(5);
   XBT_INFO("Wait another 5 seconds. The tasks stop at some point in between");
   MSG_process_sleep(5);
@@ -67,13 +61,10 @@ int main(int argc, char *argv[])
   sg_energy_plugin_init();
   MSG_init(&argc, argv);
 
   sg_energy_plugin_init();
   MSG_init(&argc, argv);
 
-  xbt_assert(argc > 1, "Usage: %s platform_file\n"
-       "\tExample: %s msg_platform.xml\n", 
-       argv[0], argv[0]);
+  xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
 
   MSG_create_environment(argv[1]);
 
 
   MSG_create_environment(argv[1]);
 
-  /*   Application deployment */
   MSG_process_create("dvfs",dvfs,NULL,MSG_host_by_name("MyHost1"));
 
   res = MSG_main();
   MSG_process_create("dvfs",dvfs,NULL,MSG_host_by_name("MyHost1"));
 
   res = MSG_main();
index 3a11d2e..77e3406 100644 (file)
@@ -4,11 +4,9 @@
 /* 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. */
 
 /* 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 "xbt/log.h"
 #include "simgrid/msg.h"
 
 #include "simgrid/msg.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test_exception,
-                             "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test_exception, "Messages specific for this msg example");
 
 /** @addtogroup MSG_examples
  * 
 
 /** @addtogroup MSG_examples
  * 
@@ -17,7 +15,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test_exception,
 
 /** Victim. This process gets a lot of remote exceptions  */
 static int victim(int argc, char *argv[]) {
 
 /** Victim. This process gets a lot of remote exceptions  */
 static int victim(int argc, char *argv[]) {
-
   xbt_ex_t e;
   msg_error_t res = MSG_OK;
   
   xbt_ex_t e;
   msg_error_t res = MSG_OK;
   
@@ -36,7 +33,6 @@ static int victim(int argc, char *argv[]) {
     xbt_ex_free(e);
   }
 
     xbt_ex_free(e);
   }
 
-
   XBT_INFO("Let's get suspended.");
   int gotit = 0;
   TRY {
   XBT_INFO("Let's get suspended.");
   int gotit = 0;
   TRY {
@@ -51,7 +47,7 @@ static int victim(int argc, char *argv[]) {
   if(!gotit) {
     xbt_die("I was expecting an exception during my suspension!");
   }
   if(!gotit) {
     xbt_die("I was expecting an exception during my suspension!");
   }
-  
+
   XBT_INFO("Let's sleep for 10 seconds.");
   TRY {
     res = MSG_process_sleep(10);
   XBT_INFO("Let's sleep for 10 seconds.");
   TRY {
     res = MSG_process_sleep(10);
@@ -71,7 +67,6 @@ static int victim(int argc, char *argv[]) {
   MSG_process_sleep(10);
 
   XBT_INFO("That's enough now. I quit.");
   MSG_process_sleep(10);
 
   XBT_INFO("That's enough now. I quit.");
-  
   return 0;
 }
 
   return 0;
 }
 
@@ -89,7 +84,6 @@ static int terrorist(int argc, char *argv[])
   XBT_INFO("Send a first exception (host failure)");
   SIMIX_process_throw(victim_process, host_error, 0, "First Trick: Let's pretend that the host failed");
 
   XBT_INFO("Send a first exception (host failure)");
   SIMIX_process_throw(victim_process, host_error, 0, "First Trick: Let's pretend that the host failed");
 
-
   XBT_INFO("Sweet, let's prepare a second trick!");
   XBT_INFO("Going to sleep for 2 seconds");
 
   XBT_INFO("Sweet, let's prepare a second trick!");
   XBT_INFO("Going to sleep for 2 seconds");
 
@@ -115,14 +109,12 @@ int main(int argc, char *argv[]) {
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-           "\tExample: %s msg_platform.xml msg_deployment.xml\n", 
-           argv[0], argv[0]);
+             "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
 
   MSG_function_register("terrorist", terrorist);
   MSG_create_environment(argv[1]);
   MSG_launch_application(argv[2]);
 
 
   MSG_function_register("terrorist", terrorist);
   MSG_create_environment(argv[1]);
   MSG_launch_application(argv[2]);
 
-
   // Launch the simulation
   res = MSG_main();
 
   // Launch the simulation
   res = MSG_main();
 
index 771352d..07f85b9 100644 (file)
@@ -9,17 +9,10 @@
  * - <b>gpu/test_MSG_gpu_task_create.c</b> Example of use of the very experimental (for now) GPU resource. 
  */
 
  * - <b>gpu/test_MSG_gpu_task_create.c</b> Example of use of the very experimental (for now) GPU resource. 
  */
 
-#include <stdio.h>
-#include <stdlib.h>
 #include "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/asserts.h"
 
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for GPU msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for GPU msg example");
 
 
-
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
index a2bed8d..83758ac 100644 (file)
@@ -4,25 +4,15 @@
 /* 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. */
 
 /* 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 <stdlib.h>
 #include "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/asserts.h"
 
 
-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");
 
 /** @addtogroup MSG_examples
  * 
  * - <b>gtnets</b> Simple ping-pong using GTNeTs instead of the SimGrid network models.
  */
 
 
 /** @addtogroup MSG_examples
  * 
  * - <b>gtnets</b> Simple ping-pong using GTNeTs instead of the SimGrid network models.
  */
 
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file);
-
 int timer_start = 1;
 
 //keep a pointer to all surf running tasks.
 int timer_start = 1;
 
 //keep a pointer to all surf running tasks.
@@ -36,8 +26,7 @@ const char *masternames[NTASKS];
 int gl_task_array_id = 0;
 int count_finished = 0;
 
 int gl_task_array_id = 0;
 int count_finished = 0;
 
-/** master */
-int master(int argc, char *argv[])
+static int master(int argc, char *argv[])
 {
   char *slavename = NULL;
   double task_comm_size = 0;
 {
   char *slavename = NULL;
   double task_comm_size = 0;
@@ -46,8 +35,7 @@ int master(int argc, char *argv[])
   //unique id to control statistics
   int id = -1;
 
   //unique id to control statistics
   int id = -1;
 
-  xbt_assert(argc == 4, "Strange number of arguments expected 3 got %d",
-             argc - 1);
+  xbt_assert(argc == 4, "Strange number of arguments expected 3 got %d", argc - 1);
 
   /* data size */
   int read;
 
   /* data size */
   int read;
@@ -80,38 +68,32 @@ int master(int argc, char *argv[])
   MSG_task_send(todo, id_alias);
   end_time = MSG_get_clock();
 
   MSG_task_send(todo, id_alias);
   end_time = MSG_get_clock();
 
-
   return 0;
   return 0;
-}                               /* end_of_master */
+}
 
 
-/** Receiver function  */
-int slave(int argc, char *argv[])
+static int slave(int argc, char *argv[])
 {
 {
-
   msg_task_t task = NULL;
   msg_task_t task = NULL;
-  int a;
-  int id = 0;
 #ifdef HAVE_LATENCY_BOUND_TRACKING
   int limited_latency = 0;
 #endif
   double remaining = 0;
   char id_alias[10];
 
 #ifdef HAVE_LATENCY_BOUND_TRACKING
   int limited_latency = 0;
 #endif
   double remaining = 0;
   char id_alias[10];
 
-  xbt_assert(argc == 2, "Strange number of arguments expected 1 got %d",
-             argc - 1);
+  xbt_assert(argc == 2, "Strange number of arguments expected 1 got %d", argc - 1);
 
 
-  id = atoi(argv[1]);
+  int id = atoi(argv[1]);
   sprintf(id_alias, "%d", id);
   int trace_id = id;
 
   sprintf(id_alias, "%d", id);
   int trace_id = id;
 
-  a = MSG_task_receive(&(task), id_alias);
+  int a = MSG_task_receive(&(task), id_alias);
 
   count_finished--;
   if(count_finished == 0){
       timer_start = 0;
   }
 
 
   count_finished--;
   if(count_finished == 0){
       timer_start = 0;
   }
 
- xbt_assert(a == MSG_OK,"Hey?! What's up? Unexpected behavior");
 xbt_assert(a == MSG_OK,"Hey?! What's up? Unexpected behavior");
 
   elapsed_time = MSG_get_clock() - start_time;
 
 
   elapsed_time = MSG_get_clock() - start_time;
 
@@ -127,15 +109,12 @@ int slave(int argc, char *argv[])
           XBT_INFO("WARNING FLOW[%d] is limited by latency!!", id);
         }
 #endif
           XBT_INFO("WARNING FLOW[%d] is limited by latency!!", id);
         }
 #endif
-        XBT_INFO
-            ("===> Estimated Bw of FLOW[%d] : %f ;  message from %s to %s  with remaining : %f",
-             id, gl_data_size[id] / elapsed_time, masternames[id],
-             slavenames[id], 0.0);
+        XBT_INFO ("===> Estimated Bw of FLOW[%d] : %f ;  message from %s to %s  with remaining : %f",
+             id, gl_data_size[id] / elapsed_time, masternames[id], slavenames[id], 0.0);
         MSG_task_destroy(gl_task_array[id]);
         gl_task_array[id]=NULL;
       } else {
         MSG_task_destroy(gl_task_array[id]);
         gl_task_array[id]=NULL;
       } else {
-        remaining =
-            MSG_task_get_remaining_communication(gl_task_array[id]);
+        remaining = MSG_task_get_remaining_communication(gl_task_array[id]);
 #ifdef HAVE_LATENCY_BOUND_TRACKING
         limited_latency = MSG_task_is_latency_bounded(gl_task_array[id]);
 
 #ifdef HAVE_LATENCY_BOUND_TRACKING
         limited_latency = MSG_task_is_latency_bounded(gl_task_array[id]);
 
@@ -143,10 +122,8 @@ int slave(int argc, char *argv[])
           XBT_INFO("WARNING FLOW[%d] is limited by latency!!", id);
         }
 #endif
           XBT_INFO("WARNING FLOW[%d] is limited by latency!!", id);
         }
 #endif
-        XBT_INFO
-            ("===> Estimated Bw of FLOW[%d] : %f ;  message from %s to %s  with remaining : %f",
-             id, (gl_data_size[id] - remaining) / elapsed_time,
-             masternames[id], slavenames[id], remaining);
+        XBT_INFO ("===> Estimated Bw of FLOW[%d] : %f ;  message from %s to %s  with remaining : %f",
+             id, (gl_data_size[id] - remaining) / elapsed_time, masternames[id], slavenames[id], remaining);
         if(remaining==0) {
           MSG_task_destroy(gl_task_array[id]);
           gl_task_array[id]=NULL;
         if(remaining==0) {
           MSG_task_destroy(gl_task_array[id]);
           gl_task_array[id]=NULL;
@@ -162,43 +139,26 @@ int slave(int argc, char *argv[])
   if(bool_printed==2 && gl_task_array[trace_id]) MSG_task_destroy(gl_task_array[trace_id]);
 
   return 0;
   if(bool_printed==2 && gl_task_array[trace_id]) MSG_task_destroy(gl_task_array[trace_id]);
 
   return 0;
-}                               /* end_of_slave */
+}
 
 
-/** Test function */
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file)
+int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 {
   msg_error_t res = MSG_OK;
+  bool_printed = 0;
 
 
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
+  MSG_init(&argc, argv);
+  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
+             "\tExample: %s platform.xml deployment.xml\n", argv[0], argv[0]);
+
+  MSG_create_environment(argv[1]);
 
   TRACE_declare_mark("endmark");
 
 
   TRACE_declare_mark("endmark");
 
-  {                             /*   Application deployment */
-    MSG_function_register("master", master);
-    MSG_function_register("slave", slave);
+  MSG_function_register("master", master);
+  MSG_function_register("slave", slave);
+  MSG_launch_application(argv[2]);
 
 
-    MSG_launch_application(application_file);
-  }
   res = MSG_main();
   res = MSG_main();
-  return res;
-}                               /* end_of_test_all */
-
-/** Main function */
-int main(int argc, char *argv[])
-{
-  msg_error_t res = MSG_OK;
-  bool_printed = 0;
-
-  MSG_init(&argc, argv);
-  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-            "\tExample: %s platform.xml deployment.xml\n", 
-            argv[0], argv[0]);
-   
-  res = test_all(argv[1], argv[2]);
 
   return res != MSG_OK;
 }
 
   return res != MSG_OK;
 }
-   
index 1e322b4..feb2564 100644 (file)
@@ -4,15 +4,9 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"            /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
 #include "simgrid/msg.h"            /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
-#include "xbt/sysdep.h"         /* calloc, printf */
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-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");
 
 /** @addtogroup MSG_examples
  * 
 
 /** @addtogroup MSG_examples
  * 
@@ -25,14 +19,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
  * 
  * - <b>msg/icomms/peer.c</b>: basic example of async functions (@ref MSG_task_isend, @ref MSG_task_irecv, @ref MSG_comm_wait)
  */
  * 
  * - <b>msg/icomms/peer.c</b>: basic example of async functions (@ref MSG_task_isend, @ref MSG_task_irecv, @ref MSG_comm_wait)
  */
-int sender(int argc, char *argv[]);
-int receiver(int argc, char *argv[]);
 
 
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file);
-
-/** Sender function  */
-int sender(int argc, char *argv[])
+static int sender(int argc, char *argv[])
 {
   long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
   double task_comp_size = xbt_str_parse_double(argv[2], "Invalid compute size: %s");
 {
   long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
   double task_comp_size = xbt_str_parse_double(argv[2], "Invalid compute size: %s");
@@ -41,8 +29,7 @@ int sender(int argc, char *argv[])
   double sleep_start_time = xbt_str_parse_double(argv[5], "Invalid sleep start time: %s");
   double sleep_test_time = xbt_str_parse_double(argv[6], "Invalid test time: %s");
 
   double sleep_start_time = xbt_str_parse_double(argv[5], "Invalid sleep start time: %s");
   double sleep_test_time = xbt_str_parse_double(argv[6], "Invalid test time: %s");
 
-  XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time,
-        sleep_test_time);
+  XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_test_time);
 
   msg_comm_t comm = NULL;
   int i;
 
   msg_comm_t comm = NULL;
   int i;
@@ -55,9 +42,7 @@ int sender(int argc, char *argv[])
     sprintf(mailbox, "receiver-%ld", i % receivers_count);
     sprintf(sprintf_buffer, "Task_%d", i);
 
     sprintf(mailbox, "receiver-%ld", i % receivers_count);
     sprintf(sprintf_buffer, "Task_%d", i);
 
-    task =
-        MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
-                        NULL);
+    task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
     comm = MSG_task_isend(task, mailbox);
     XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
 
     comm = MSG_task_isend(task, mailbox);
     XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
 
@@ -69,7 +54,6 @@ int sender(int argc, char *argv[])
       };
     }
     MSG_comm_destroy(comm);
       };
     }
     MSG_comm_destroy(comm);
-
   }
 
   for (i = 0; i < receivers_count; i++) {
   }
 
   for (i = 0; i < receivers_count; i++) {
@@ -86,15 +70,13 @@ int sender(int argc, char *argv[])
       };
     }
     MSG_comm_destroy(comm);
       };
     }
     MSG_comm_destroy(comm);
-
   }
 
   XBT_INFO("Goodbye now!");
   return 0;
   }
 
   XBT_INFO("Goodbye now!");
   return 0;
-}                               /* end_of_sender */
+}
 
 
-/** Receiver function  */
-int receiver(int argc, char *argv[])
+static int receiver(int argc, char *argv[])
 {
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED msg_error_t res;
 {
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED msg_error_t res;
@@ -103,13 +85,11 @@ int receiver(int argc, char *argv[])
   msg_comm_t res_irecv;
   double sleep_start_time = xbt_str_parse_double(argv[2], "Invalid sleep start parameter: %s");
   double sleep_test_time = xbt_str_parse_double(argv[3], "Invalid sleep test parameter: %s");
   msg_comm_t res_irecv;
   double sleep_start_time = xbt_str_parse_double(argv[2], "Invalid sleep start parameter: %s");
   double sleep_test_time = xbt_str_parse_double(argv[3], "Invalid sleep test parameter: %s");
-  XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time,
-        sleep_test_time);
+  XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_test_time);
 
   XBT_ATTRIB_UNUSED int read;
   read = sscanf(argv[1], "%d", &id);
 
   XBT_ATTRIB_UNUSED int read;
   read = sscanf(argv[1], "%d", &id);
-  xbt_assert(read,
-              "Invalid argument %s\n", argv[1]);
+  xbt_assert(read, "Invalid argument %s\n", argv[1]);
 
   MSG_process_sleep(sleep_start_time);
 
 
   MSG_process_sleep(sleep_start_time);
 
@@ -142,40 +122,25 @@ int receiver(int argc, char *argv[])
   }
   XBT_INFO("I'm done. See you!");
   return 0;
   }
   XBT_INFO("I'm done. See you!");
   return 0;
-}                               /* end_of_receiver */
-
-/** Test function */
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file)
-{
-  msg_error_t res = MSG_OK;
-
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("sender", sender);
-    MSG_function_register("receiver", receiver);
-    MSG_launch_application(application_file);
-  }
-  res = MSG_main();
-
-  XBT_INFO("Simulation time %g", MSG_get_clock());
-  return res;
-}                               /* end_of_test_all */
-
+}
 
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-           "\tExample: %s msg_platform.xml msg_deployment.xml\n", 
-           argv[0], argv[0]);
+             "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
 
 
-  res = test_all(argv[1], argv[2]);
+  MSG_create_environment(argv[1]);
+
+  MSG_function_register("sender", sender);
+  MSG_function_register("receiver", receiver);
+  MSG_launch_application(argv[2]);
+
+  res = MSG_main();
+
+  XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
 }
 
   return res != MSG_OK;
 }
index a2cf462..73823ea 100644 (file)
@@ -4,29 +4,16 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"            /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
-#include "xbt/sysdep.h"         /* calloc, printf */
+#include "simgrid/msg.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-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");
 
 /** @addtogroup MSG_examples
  * 
  * - <b>msg/icomms/peer2.c</b>: demonstrates the @ref MSG_comm_waitall function
  */
 
 
 /** @addtogroup MSG_examples
  * 
  * - <b>msg/icomms/peer2.c</b>: demonstrates the @ref MSG_comm_waitall function
  */
 
-int sender(int argc, char *argv[]);
-int receiver(int argc, char *argv[]);
-
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file);
-
-/** Sender function  */
-int sender(int argc, char *argv[])
+static int sender(int argc, char *argv[])
 {
   long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
   double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
 {
   long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
   double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
@@ -63,10 +50,9 @@ int sender(int argc, char *argv[])
   XBT_INFO("Goodbye now!");
   xbt_free(comm);
   return 0;
   XBT_INFO("Goodbye now!");
   xbt_free(comm);
   return 0;
-}                               /* end_of_sender */
+}
 
 
-/** Receiver function  */
-int receiver(int argc, char *argv[])
+static int receiver(int argc, char *argv[])
 {
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED msg_error_t res;
 {
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED msg_error_t res;
@@ -98,40 +84,24 @@ int receiver(int argc, char *argv[])
   }
   XBT_INFO("I'm done. See you!");
   return 0;
   }
   XBT_INFO("I'm done. See you!");
   return 0;
-}                               /* end_of_receiver */
-
-/** Test function */
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file)
-{
-  msg_error_t res = MSG_OK;
-
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("sender", sender);
-    MSG_function_register("receiver", receiver);
-    MSG_launch_application(application_file);
-  }
-  res = MSG_main();
-
-  XBT_INFO("Simulation time %g", MSG_get_clock());
-  return res;
-}                               /* end_of_test_all */
-
+}
 
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-           "\tExample: %s msg_platform.xml msg_deployment.xml\n", 
-           argv[0], argv[0]);
+             "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
 
 
-  res = test_all(argv[1], argv[2]);
+  MSG_create_environment(argv[1]);
+  MSG_function_register("sender", sender);
+  MSG_function_register("receiver", receiver);
+  MSG_launch_application(argv[2]);
+
+  res = MSG_main();
+
+  XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
 }
 
   return res != MSG_OK;
 }
index a0fe6c6..818f891 100644 (file)
@@ -4,29 +4,16 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"            /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
-#include "xbt/sysdep.h"         /* calloc, printf */
-#include <math.h>
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for this msg example");
+#include "simgrid/msg.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 /** @addtogroup MSG_examples
  * 
  * - <b>msg/icomms/peer3.c</b>: demonstrates the @ref MSG_comm_waitany function
  */
 
 
 /** @addtogroup MSG_examples
  * 
  * - <b>msg/icomms/peer3.c</b>: demonstrates the @ref MSG_comm_waitany function
  */
 
-int sender(int argc, char *argv[]);
-int receiver(int argc, char *argv[]);
-
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file);
-
-/** Sender function  */
-int sender(int argc, char *argv[])
+static int sender(int argc, char *argv[])
 {
   long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
   double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
 {
   long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
   double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
@@ -54,8 +41,7 @@ int sender(int argc, char *argv[])
                         task_comm_size / coef, NULL);
     comm = MSG_task_isend(task, mailbox);
     xbt_dynar_push_as(d, msg_comm_t, comm);
                         task_comm_size / coef, NULL);
     comm = MSG_task_isend(task, mailbox);
     xbt_dynar_push_as(d, msg_comm_t, comm);
-    XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count,
-          sprintf_buffer, task_comm_size / coef);
+    XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, sprintf_buffer, task_comm_size / coef);
   }
   /* Here we are waiting for the completion of all communications */
 
   }
   /* Here we are waiting for the completion of all communications */
 
@@ -81,13 +67,11 @@ int sender(int argc, char *argv[])
 
   XBT_INFO("Goodbye now!");
   return 0;
 
   XBT_INFO("Goodbye now!");
   return 0;
-}                               /* end_of_sender */
+}
 
 
-/** Receiver function  */
-int receiver(int argc, char *argv[])
+static int receiver(int argc, char *argv[])
 {
   int id = -1;
 {
   int id = -1;
-  int i;
   char mailbox[80];
   xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL);
   int tasks = xbt_str_parse_int(argv[2], "Invalid amount of tasks: %s");
   char mailbox[80];
   xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL);
   int tasks = xbt_str_parse_int(argv[2], "Invalid amount of tasks: %s");
@@ -99,7 +83,7 @@ int receiver(int argc, char *argv[])
   sprintf(mailbox, "receiver-%d", id);
   MSG_process_sleep(10);
   msg_comm_t res_irecv;
   sprintf(mailbox, "receiver-%d", id);
   MSG_process_sleep(10);
   msg_comm_t res_irecv;
-  for (i = 0; i < tasks; i++) {
+  for (int i = 0; i < tasks; i++) {
     XBT_INFO("Wait to receive task %d", i);
     task[i] = NULL;
     res_irecv = MSG_task_irecv(&task[i], mailbox);
     XBT_INFO("Wait to receive task %d", i);
     task[i] = NULL;
     res_irecv = MSG_task_irecv(&task[i], mailbox);
@@ -129,40 +113,25 @@ int receiver(int argc, char *argv[])
   MSG_comm_destroy(res_irecv);
   XBT_INFO("I'm done. See you!");
   return 0;
   MSG_comm_destroy(res_irecv);
   XBT_INFO("I'm done. See you!");
   return 0;
-}                               /* end_of_receiver */
+}
 
 
-/** Test function */
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file)
+int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
 {
   msg_error_t res = MSG_OK;
 
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("sender", sender);
-    MSG_function_register("receiver", receiver);
-    MSG_launch_application(application_file);
-  }
-  res = MSG_main();
+  MSG_init(&argc, argv);
+  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
+                  "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
 
 
-  XBT_INFO("Simulation time %g", MSG_get_clock());
-  return res;
-}                               /* end_of_test_all */
+  MSG_create_environment(argv[1]);
 
 
+  MSG_function_register("sender", sender);
+  MSG_function_register("receiver", receiver);
+  MSG_launch_application(argv[2]);
 
 
-/** Main function */
-int main(int argc, char *argv[])
-{
-  msg_error_t res = MSG_OK;
+  res = MSG_main();
+
+  XBT_INFO("Simulation time %g", MSG_get_clock());
 
 
-  MSG_init(&argc, argv);
-  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-                  "\tExample: %s msg_platform.xml msg_deployment.xml\n",
-                  argv[0], argv[0]);
-   
-  res = test_all(argv[1], argv[2]);
-   
   return res != MSG_OK;
 }
   return res != MSG_OK;
 }
index e42f2b6..c72e615 100644 (file)
 #define FILENAME3 "/home/doc/simgrid/examples/platforms/g5k_cabinets.xml"
 #define FILENAME4 "/home/doc/simgrid/examples/platforms/nancy.xml"
 
 #define FILENAME3 "/home/doc/simgrid/examples/platforms/g5k_cabinets.xml"
 #define FILENAME4 "/home/doc/simgrid/examples/platforms/nancy.xml"
 
-#include <stdio.h>
-#include <stdlib.h>
 #include "simgrid/msg.h"
 
 #include "simgrid/msg.h"
 
-int host(int argc, char *argv[]);
+XBT_LOG_NEW_DEFAULT_CATEGORY(io_file, "Messages specific for this io example");
 
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(io_file,
-                             "Messages specific for this io example");
-
-int host(int argc, char *argv[])
+static int host(int argc, char *argv[])
 {
   msg_file_t file = NULL;
   sg_size_t read,write;
 {
   msg_file_t file = NULL;
   sg_size_t read,write;
@@ -65,32 +60,27 @@ int host(int argc, char *argv[])
 
   /* Write 100KB in file from the current position, i.e, end of file or 10MB */
   write = MSG_file_write(file, 100000);
 
   /* Write 100KB in file from the current position, i.e, end of file or 10MB */
   write = MSG_file_write(file, 100000);
-  XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu",write,filename,
-           MSG_file_get_size(file));
+  XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu",write,filename, MSG_file_get_size(file));
 
 
   XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
             filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
 
   /* rewind to the beginning of the file */
 
 
   XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
             filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
 
   /* rewind to the beginning of the file */
-  XBT_INFO("\tComing back to the beginning of the stream for file '%s'",
-           filename);
+  XBT_INFO("\tComing back to the beginning of the stream for file '%s'", filename);
   MSG_file_seek(file, 0, SEEK_SET);
 
   /* Try to read 110KB */
   read = MSG_file_read(file, 110000);
   MSG_file_seek(file, 0, SEEK_SET);
 
   /* Try to read 110KB */
   read = MSG_file_read(file, 110000);
-  XBT_INFO("\tHave read %llu from '%s' (of size %llu)",read,filename,
-      MSG_file_get_size(file));
+  XBT_INFO("\tHave read %llu from '%s' (of size %llu)",read,filename, MSG_file_get_size(file));
 
   /* rewind once again to the beginning of the file */
 
   /* rewind once again to the beginning of the file */
-  XBT_INFO("\tComing back to the beginning of the stream for file '%s'",
-           filename);
+  XBT_INFO("\tComing back to the beginning of the stream for file '%s'", filename);
   MSG_file_seek(file, 0, SEEK_SET);
 
   /* Write 110KB in file from the current position, i.e, end of file or 10MB */
   write = MSG_file_write(file, 110000);
   MSG_file_seek(file, 0, SEEK_SET);
 
   /* Write 110KB in file from the current position, i.e, end of file or 10MB */
   write = MSG_file_write(file, 110000);
-  XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write,filename,
-      MSG_file_get_size(file));
+  XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write,filename, MSG_file_get_size(file));
 
   XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
             filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
 
   XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu",
             filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st));
@@ -98,28 +88,25 @@ int host(int argc, char *argv[])
   XBT_INFO("\tClose file '%s'",filename);
   MSG_file_close(file);
 
   XBT_INFO("\tClose file '%s'",filename);
   MSG_file_close(file);
 
-
   return 0;
 }
 
 int main(int argc, char **argv)
 {
   return 0;
 }
 
 int main(int argc, char **argv)
 {
-  int i,res;
   MSG_init(&argc, argv);
   MSG_create_environment(argv[1]);
   xbt_dynar_t hosts =  MSG_hosts_as_dynar();
   MSG_function_register("host", host);
   unsigned long nb_hosts = xbt_dynar_length(hosts);
   XBT_INFO("Number of host '%lu'",nb_hosts);
   MSG_init(&argc, argv);
   MSG_create_environment(argv[1]);
   xbt_dynar_t hosts =  MSG_hosts_as_dynar();
   MSG_function_register("host", host);
   unsigned long nb_hosts = xbt_dynar_length(hosts);
   XBT_INFO("Number of host '%lu'",nb_hosts);
-  for(i = 0 ; i<nb_hosts; i++)
-  {
+  for(int i = 0 ; i<nb_hosts; i++){
     char* name_host = bprintf("%d",i);
     MSG_process_create( name_host, host, NULL, xbt_dynar_get_as(hosts,i,msg_host_t) );
     free(name_host);
   }
   xbt_dynar_free(&hosts);
 
     char* name_host = bprintf("%d",i);
     MSG_process_create( name_host, host, NULL, xbt_dynar_get_as(hosts,i,msg_host_t) );
     free(name_host);
   }
   xbt_dynar_free(&hosts);
 
-  res = MSG_main();
+  int res = MSG_main();
   XBT_INFO("Simulation time %g", MSG_get_clock());
   return res != MSG_OK;
 }
   XBT_INFO("Simulation time %g", MSG_get_clock());
   return res != MSG_OK;
 }
index 34f7dc0..0426d20 100644 (file)
 
 #define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
 
 
 #define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
 
-#include <stdio.h>
-#include <stdlib.h>
 #include "simgrid/msg.h"
 
 #include "simgrid/msg.h"
 
-int host(int argc, char *argv[]);
+XBT_LOG_NEW_DEFAULT_CATEGORY(io_file, "Messages specific for this io example");
 
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(io_file,
-                             "Messages specific for this io example");
-
-int host(int argc, char *argv[])
+static int host(int argc, char *argv[])
 {
 {
-  msg_file_t file = NULL;
-  sg_size_t write;
-
   // First open
   XBT_INFO("\tOpen file '%s'",FILENAME1);
   // First open
   XBT_INFO("\tOpen file '%s'",FILENAME1);
-  file = MSG_file_open(FILENAME1, NULL);
+  msg_file_t file = MSG_file_open(FILENAME1, NULL);
 
   // Unlink the file
   XBT_INFO("\tUnlink file '%s'",MSG_file_get_name(file));
 
   // Unlink the file
   XBT_INFO("\tUnlink file '%s'",MSG_file_get_name(file));
@@ -38,7 +30,7 @@ int host(int argc, char *argv[])
   file = MSG_file_open(FILENAME1, NULL);
 
   // Write into the new file
   file = MSG_file_open(FILENAME1, NULL);
 
   // Write into the new file
-  write = MSG_file_write(file,100000);  // Write for 100Ko
+  sg_size_t write = MSG_file_write(file,100000);  // Write for 100Ko
   XBT_INFO("\tHave written %llu on %s",write,MSG_file_get_name(file));
 
   // Write into the new file
   XBT_INFO("\tHave written %llu on %s",write,MSG_file_get_name(file));
 
   // Write into the new file
@@ -54,7 +46,6 @@ int host(int argc, char *argv[])
 
 int main(int argc, char **argv)
 {
 
 int main(int argc, char **argv)
 {
-  int res;
   MSG_init(&argc, argv);
   MSG_create_environment(argv[1]);
   xbt_dynar_t hosts =  MSG_hosts_as_dynar();
   MSG_init(&argc, argv);
   MSG_create_environment(argv[1]);
   xbt_dynar_t hosts =  MSG_hosts_as_dynar();
@@ -67,7 +58,7 @@ int main(int argc, char **argv)
 
   xbt_dynar_free(&hosts);
 
 
   xbt_dynar_free(&hosts);
 
-  res = MSG_main();
+  int res = MSG_main();
   XBT_INFO("Simulation time %g", MSG_get_clock());
   return res != MSG_OK;
 }
   XBT_INFO("Simulation time %g", MSG_get_clock());
   return res != MSG_OK;
 }
index cc84983..0d90d37 100644 (file)
@@ -9,32 +9,21 @@
  * - <b>io/remote.c</b> Example of delegated I/O operations
  */
 
  * - <b>io/remote.c</b> Example of delegated I/O operations
  */
 
-#include <stdio.h>
-#include <stdlib.h>
 #include "simgrid/msg.h"
 
 #define INMEGA (1024*1024)
 
 #include "simgrid/msg.h"
 
 #define INMEGA (1024*1024)
 
-int host(int argc, char *argv[]);
+XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io, "Messages specific for this io example");
 
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io,
-                             "Messages specific for this io example");
-
-
-int host(int argc, char *argv[]){
-  msg_file_t file = NULL;
-  const char* filename;
-  sg_size_t read, write;
-
-  file = MSG_file_open(argv[1], NULL);
-  filename = MSG_file_get_name(file);
+static int host(int argc, char *argv[]){
+  msg_file_t file = MSG_file_open(argv[1], NULL);
+  char *filename = MSG_file_get_name(file);
   XBT_INFO("Opened file '%s'",filename);
   MSG_file_dump(file);
 
   XBT_INFO("Try to read %llu from '%s'",MSG_file_get_size(file),filename);
   XBT_INFO("Opened file '%s'",filename);
   MSG_file_dump(file);
 
   XBT_INFO("Try to read %llu from '%s'",MSG_file_get_size(file),filename);
-  read = MSG_file_read(file, MSG_file_get_size(file));
-  XBT_INFO("Have read %llu from '%s'. Offset is now at: %llu",read,filename,
-      MSG_file_tell(file));
+  sg_size_t read = MSG_file_read(file, MSG_file_get_size(file));
+  XBT_INFO("Have read %llu from '%s'. Offset is now at: %llu",read,filename, MSG_file_tell(file));
   XBT_INFO("Seek back to the begining of the stream...");
   MSG_file_seek(file, 0, SEEK_SET);
   XBT_INFO("Offset is now at: %llu", MSG_file_tell(file));
   XBT_INFO("Seek back to the begining of the stream...");
   MSG_file_seek(file, 0, SEEK_SET);
   XBT_INFO("Offset is now at: %llu", MSG_file_tell(file));
@@ -45,24 +34,20 @@ int host(int argc, char *argv[]){
     file = MSG_file_open(argv[2], NULL);
     filename = MSG_file_get_name(file);
     XBT_INFO("Opened file '%s'",filename);
     file = MSG_file_open(argv[2], NULL);
     filename = MSG_file_get_name(file);
     XBT_INFO("Opened file '%s'",filename);
-    XBT_INFO("Try to write %llu MiB to '%s'",
-        MSG_file_get_size(file)/1024,
-        filename);
-    write = MSG_file_write(file, MSG_file_get_size(file)*1024);
+    XBT_INFO("Try to write %llu MiB to '%s'", MSG_file_get_size(file)/1024, filename);
+    sg_size_t write = MSG_file_write(file, MSG_file_get_size(file)*1024);
     XBT_INFO("Have written %llu bytes to '%s'.",write,filename);
 
     msg_host_t src, dest;
     src= MSG_host_self();
     dest = MSG_host_by_name(argv[3]);
     if (xbt_str_parse_int(argv[5], "Argument 5 (move or copy) must be an int, not '%s'")) {
     XBT_INFO("Have written %llu bytes to '%s'.",write,filename);
 
     msg_host_t src, dest;
     src= MSG_host_self();
     dest = MSG_host_by_name(argv[3]);
     if (xbt_str_parse_int(argv[5], "Argument 5 (move or copy) must be an int, not '%s'")) {
-      XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename,
-           MSG_file_get_size(file), MSG_host_get_name(src),
-           argv[3]);
+      XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename,MSG_file_get_size(file), MSG_host_get_name(src),
+               argv[3]);
       MSG_file_rmove(file, dest, argv[4]);
     } else {
       MSG_file_rmove(file, dest, argv[4]);
     } else {
-      XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename,
-           MSG_file_get_size(file), MSG_host_get_name(src),
-           argv[3]);
+      XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, MSG_file_get_size(file), MSG_host_get_name(src),
+               argv[3]);
       MSG_file_rcopy(file, dest, argv[4]);
       MSG_file_close(file);
     }
       MSG_file_rcopy(file, dest, argv[4]);
       MSG_file_close(file);
     }
@@ -71,13 +56,9 @@ int host(int argc, char *argv[]){
   return 0;
 }
 
   return 0;
 }
 
-
-
 int main(int argc, char **argv)
 {
 int main(int argc, char **argv)
 {
-  int res;
   unsigned int cur;
   unsigned int cur;
-  xbt_dynar_t storages;
   msg_storage_t st;
 
   MSG_init(&argc, argv);
   msg_storage_t st;
 
   MSG_init(&argc, argv);
@@ -85,19 +66,15 @@ int main(int argc, char **argv)
   MSG_function_register("host", host);
   MSG_launch_application(argv[2]);
 
   MSG_function_register("host", host);
   MSG_launch_application(argv[2]);
 
-  storages = MSG_storages_as_dynar();
+  xbt_dynar_t storages = MSG_storages_as_dynar();
   xbt_dynar_foreach(storages, cur, st){
   xbt_dynar_foreach(storages, cur, st){
-    XBT_INFO("Init: %llu MiB used on '%s'",
-        MSG_storage_get_used_size(st)/INMEGA,
-        MSG_storage_get_name(st));
+    XBT_INFO("Init: %llu MiB used on '%s'", MSG_storage_get_used_size(st)/INMEGA, MSG_storage_get_name(st));
   }
 
   }
 
-  res = MSG_main();
+  int res = MSG_main();
 
   xbt_dynar_foreach(storages, cur, st){
 
   xbt_dynar_foreach(storages, cur, st){
-    XBT_INFO("Init: %llu MiB used on '%s'",
-        MSG_storage_get_used_size(st)/INMEGA,
-        MSG_storage_get_name(st));
+    XBT_INFO("Init: %llu MiB used on '%s'", MSG_storage_get_used_size(st)/INMEGA, MSG_storage_get_name(st));
   }
   xbt_dynar_free_container(&storages);
 
   }
   xbt_dynar_free_container(&storages);
 
index ddae501..ce10c42 100644 (file)
@@ -24,8 +24,6 @@
 ******************************************************************************/
 
 #include "simgrid/msg.h"
 ******************************************************************************/
 
 #include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/dict.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
 
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
 
@@ -59,7 +57,6 @@ static int host(int argc, char *argv[]){
   }
   xbt_dict_free(&storage_list);
 
   }
   xbt_dict_free(&storage_list);
 
-
   // Create a 200,000 bytes file named './tmp/data.txt' on /sd1
   char* file_name = xbt_strdup("/home/tmp/data.txt");
   msg_file_t file = NULL;
   // Create a 200,000 bytes file named './tmp/data.txt' on /sd1
   char* file_name = xbt_strdup("/home/tmp/data.txt");
   msg_file_t file = NULL;
@@ -75,7 +72,6 @@ static int host(int argc, char *argv[]){
   XBT_INFO("Free size: %llu bytes", MSG_storage_get_free_size(storage));
   XBT_INFO("Used size: %llu bytes", MSG_storage_get_used_size(storage));
 
   XBT_INFO("Free size: %llu bytes", MSG_storage_get_free_size(storage));
   XBT_INFO("Used size: %llu bytes", MSG_storage_get_used_size(storage));
 
-
   // Now retrieve the size of created file and read it completely
   file_size = MSG_file_get_size(file);
   MSG_file_seek(file, 0, SEEK_SET);
   // Now retrieve the size of created file and read it completely
   file_size = MSG_file_get_size(file);
   MSG_file_seek(file, 0, SEEK_SET);
@@ -116,7 +112,6 @@ static int host(int argc, char *argv[]){
   xbt_free(data);
   xbt_free(storage_name);
 
   xbt_free(data);
   xbt_free(storage_name);
 
-
   // Dump disks contents
   XBT_INFO("*** Dump content of %s ***",MSG_host_get_name(MSG_host_self()));
   xbt_dict_t contents = NULL;
   // Dump disks contents
   XBT_INFO("*** Dump content of %s ***",MSG_host_get_name(MSG_host_self()));
   xbt_dict_t contents = NULL;
@@ -137,10 +132,8 @@ static int host(int argc, char *argv[]){
   return 1;
 }
 
   return 1;
 }
 
-
 int main(int argc, char *argv[])
 {
 int main(int argc, char *argv[])
 {
-
   MSG_init(&argc, argv);
   MSG_create_environment(argv[1]);
   MSG_function_register("host", host);
   MSG_init(&argc, argv);
   MSG_create_environment(argv[1]);
   MSG_function_register("host", host);
index f7e2195..6eae1ee 100644 (file)
@@ -9,8 +9,6 @@
 #include "task.h"
 
 #include "simgrid/msg.h"
 #include "task.h"
 
 #include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/asserts.h"
 /** @addtogroup MSG_examples
   * <b>kademlia/kademlia.c: Kademlia protocol</b>
   * Implements the Kademlia protocol, using 32 bits identifiers.
 /** @addtogroup MSG_examples
   * <b>kademlia/kademlia.c: Kademlia protocol</b>
   * Implements the Kademlia protocol, using 32 bits identifiers.
index bc0c9e5..08aa37c 100644 (file)
@@ -6,10 +6,8 @@
 
 #include "node.h"
 #include "routing_table.h"
 
 #include "node.h"
 #include "routing_table.h"
-
 #include "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/asserts.h"
+
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia_node, "Messages specific for this msg example");
 
 /** @brief Initialization of a node
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia_node, "Messages specific for this msg example");
 
 /** @brief Initialization of a node
index dae7c95..20757af 100644 (file)
@@ -7,8 +7,7 @@
 #include "routing_table.h"
 #include "node.h"
 #include "simgrid/msg.h"
 #include "routing_table.h"
 #include "node.h"
 #include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/asserts.h"
+
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia_routing_table, "Messages specific for this msg example");
 
 /** @brief Initialization of a node routing table.  */
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia_routing_table, "Messages specific for this msg example");
 
 /** @brief Initialization of a node routing table.  */
index 611b26d..b859965 100644 (file)
@@ -4,15 +4,9 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"        /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
-#include "xbt/sysdep.h"         /* calloc, printf */
+#include "simgrid/msg.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-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");
 
 #define task_comp_size 50000000
 #define task_comm_size 1000000
 
 #define task_comp_size 50000000
 #define task_comm_size 1000000
@@ -25,7 +19,6 @@ static long my_random(long n)
   return n * (rand() / ((double)RAND_MAX + 1));
 }
 
   return n * (rand() / ((double)RAND_MAX + 1));
 }
 
-/** Emitter function  */
 static int master(int argc, char *argv[])
 {
   int i;
 static int master(int argc, char *argv[])
 {
   int i;
@@ -38,8 +31,7 @@ static int master(int argc, char *argv[])
     sprintf(mailbox, "slave-%ld", i % number_of_slaves);
     sprintf(sprintf_buffer, "Task_%d", i);
     task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
     sprintf(mailbox, "slave-%ld", i % number_of_slaves);
     sprintf(sprintf_buffer, "Task_%d", i);
     task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
-    XBT_DEBUG("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name,
-          number_of_jobs, mailbox);
+    XBT_DEBUG("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_jobs, mailbox);
 
     MSG_task_send(task, mailbox);
   }
 
     MSG_task_send(task, mailbox);
   }
@@ -55,9 +47,8 @@ static int master(int argc, char *argv[])
 
   XBT_DEBUG("Goodbye now!");
   return 0;
 
   XBT_DEBUG("Goodbye now!");
   return 0;
-}                               /* end_of_master */
+}
 
 
-/** Receiver function  */
 static int slave(int argc, char *argv[])
 {
   msg_task_t task = NULL;
 static int slave(int argc, char *argv[])
 {
   msg_task_t task = NULL;
@@ -80,9 +71,8 @@ static int slave(int argc, char *argv[])
     task = NULL;
   }
   return 0;
     task = NULL;
   }
   return 0;
-}                               /* end_of_slave */                              /* end_of_test_all */
+}
 
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
@@ -90,8 +80,7 @@ int main(int argc, char *argv[])
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 3, "Usage: %s platform_file number_of_jobs number_of_slaves\n"
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 3, "Usage: %s platform_file number_of_jobs number_of_slaves\n"
-            "\tExample: %s msg_platform.xml 10 5\n", 
-            argv[0], argv[0]);
+             "\tExample: %s msg_platform.xml 10 5\n", argv[0], argv[0]);
 
   MSG_function_register("master", master);
   MSG_function_register("slave", slave);
 
   MSG_function_register("master", master);
   MSG_function_register("slave", slave);
@@ -106,17 +95,11 @@ int main(int argc, char *argv[])
 
   msg_host_t *host_table =  xbt_dynar_to_array(host_dynar);
 
 
   msg_host_t *host_table =  xbt_dynar_to_array(host_dynar);
 
-  MSG_process_create( "master", master,
-                      NULL,
-                      host_table[my_random(number_max)]
-                      );
+  MSG_process_create("master", master, NULL, host_table[my_random(number_max)]);
 
   for(i = 0 ; i<number_of_slaves; i++) {
     char* name_host = bprintf("slave-%ld",i);
 
   for(i = 0 ; i<number_of_slaves; i++) {
     char* name_host = bprintf("slave-%ld",i);
-      MSG_process_create( name_host, slave,
-                          NULL,
-                          host_table[my_random(number_max)]
-                          );
+      MSG_process_create( name_host, slave, NULL, host_table[my_random(number_max)]);
       free(name_host);
   }
   xbt_free(host_table);
       free(name_host);
   }
   xbt_free(host_table);
index 2b1b372..070d75a 100644 (file)
@@ -4,25 +4,13 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"        /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
-#include "xbt/sysdep.h"         /* calloc, printf */
+#include "simgrid/msg.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for this msg example");
-
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file);
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 #define FINALIZE ((void*)221297)        /* a magic number to tell people to stop working */
 
 
 #define FINALIZE ((void*)221297)        /* a magic number to tell people to stop working */
 
-/** Emitter function  */
-int master(int argc, char *argv[])
+static int master(int argc, char *argv[])
 {
   int slaves_count = 0;
   msg_host_t *slaves = NULL;
 {
   int slaves_count = 0;
   msg_host_t *slaves = NULL;
@@ -59,31 +47,26 @@ int master(int argc, char *argv[])
   XBT_INFO("Got %d task to process :", number_of_tasks);
 
   for (i = 0; i < number_of_tasks; i++) {
   XBT_INFO("Got %d task to process :", number_of_tasks);
 
   for (i = 0; i < number_of_tasks; i++) {
-    msg_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size,
-                                    xbt_new0(double, 1));
-    msg_error_t a;
+    msg_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size, xbt_new0(double, 1));
     *((double *) task->data) = MSG_get_clock();
 
     *((double *) task->data) = MSG_get_clock();
 
-    a = MSG_task_send_with_timeout(task,MSG_host_get_name(slaves[i % slaves_count]),10.0);
+    msg_error_t a = MSG_task_send_with_timeout(task,MSG_host_get_name(slaves[i % slaves_count]),10.0);
 
     if (a == MSG_OK) {
       XBT_INFO("Send completed");
     } else if (a == MSG_HOST_FAILURE) {
 
     if (a == MSG_OK) {
       XBT_INFO("Send completed");
     } else if (a == MSG_HOST_FAILURE) {
-      XBT_INFO
-          ("Gloups. The cpu on which I'm running just turned off!. See you!");
+      XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
       free(task->data);
       MSG_task_destroy(task);
       free(slaves);
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
       free(task->data);
       MSG_task_destroy(task);
       free(slaves);
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
-      XBT_INFO
-          ("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!",
-              MSG_host_get_name(slaves[i % slaves_count]));
+      XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!",
+               MSG_host_get_name(slaves[i % slaves_count]));
       free(task->data);
       MSG_task_destroy(task);
     } else if (a == MSG_TIMEOUT) {
       free(task->data);
       MSG_task_destroy(task);
     } else if (a == MSG_TIMEOUT) {
-      XBT_INFO
-          ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
+      XBT_INFO ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
               MSG_host_get_name(slaves[i % slaves_count]));
       free(task->data);
       MSG_task_destroy(task);
               MSG_host_get_name(slaves[i % slaves_count]));
       free(task->data);
       MSG_task_destroy(task);
@@ -93,27 +76,23 @@ int master(int argc, char *argv[])
     }
   }
 
     }
   }
 
-  XBT_INFO
-      ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+  XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
   for (i = 0; i < slaves_count; i++) {
     msg_task_t task = MSG_task_create("finalize", 0, 0, FINALIZE);
     int a = MSG_task_send_with_timeout(task,MSG_host_get_name(slaves[i]),1.0);
     if (a == MSG_OK)
       continue;
     if (a == MSG_HOST_FAILURE) {
   for (i = 0; i < slaves_count; i++) {
     msg_task_t task = MSG_task_create("finalize", 0, 0, FINALIZE);
     int a = MSG_task_send_with_timeout(task,MSG_host_get_name(slaves[i]),1.0);
     if (a == MSG_OK)
       continue;
     if (a == MSG_HOST_FAILURE) {
-      XBT_INFO
-          ("Gloups. The cpu on which I'm running just turned off!. See you!");
+      XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
       MSG_task_destroy(task);
       free(slaves);
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
       MSG_task_destroy(task);
       free(slaves);
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
-      XBT_INFO("Mmh. Can't reach '%s'! Nevermind. Let's keep going!",
-          MSG_host_get_name(slaves[i]));
+      XBT_INFO("Mmh. Can't reach '%s'! Nevermind. Let's keep going!", MSG_host_get_name(slaves[i]));
       MSG_task_destroy(task);
     } else if (a == MSG_TIMEOUT) {
       MSG_task_destroy(task);
     } else if (a == MSG_TIMEOUT) {
-      XBT_INFO
-          ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
-              MSG_host_get_name(slaves[i % slaves_count]));
+      XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
+               MSG_host_get_name(slaves[i % slaves_count]));
       MSG_task_destroy(task);
     } else {
       XBT_INFO("Hey ?! What's up ? ");
       MSG_task_destroy(task);
     } else {
       XBT_INFO("Hey ?! What's up ? ");
@@ -124,10 +103,9 @@ int master(int argc, char *argv[])
   XBT_INFO("Goodbye now!");
   free(slaves);
   return 0;
   XBT_INFO("Goodbye now!");
   free(slaves);
   return 0;
-}                               /* end_of_master */
+}
 
 
-/** Receiver function  */
-int slave(int argc, char *argv[])
+static int slave(int argc, char *argv[])
 {
   while (1) {
     msg_task_t task = NULL;
 {
   while (1) {
     msg_task_t task = NULL;
@@ -153,8 +131,7 @@ int slave(int argc, char *argv[])
         free(task->data);
         MSG_task_destroy(task);
       } else if (a == MSG_HOST_FAILURE) {
         free(task->data);
         MSG_task_destroy(task);
       } else if (a == MSG_HOST_FAILURE) {
-        XBT_INFO
-            ("Gloups. The cpu on which I'm running just turned off!. See you!");
+        XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
         free(task->data);
         MSG_task_destroy(task);
         return 0;
         free(task->data);
         MSG_task_destroy(task);
         return 0;
@@ -163,8 +140,7 @@ int slave(int argc, char *argv[])
         xbt_die("Unexpected behavior");
       }
     } else if (a == MSG_HOST_FAILURE) {
         xbt_die("Unexpected behavior");
       }
     } else if (a == MSG_HOST_FAILURE) {
-      XBT_INFO
-          ("Gloups. The cpu on which I'm running just turned off!. See you!");
+      XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
       XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!");
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
       XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!");
@@ -175,40 +151,25 @@ int slave(int argc, char *argv[])
   }
   XBT_INFO("I'm done. See you!");
   return 0;
   }
   XBT_INFO("I'm done. See you!");
   return 0;
-}                               /* end_of_slave */
+}
 
 
-/** Test function */
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file)
+int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
 {
   msg_error_t res = MSG_OK;
 
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("master", master);
-    MSG_function_register("slave", slave);
-    MSG_launch_application(application_file);
-  }
-  res = MSG_main();
+  MSG_init(&argc, argv);
+  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
+             "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
 
 
-  XBT_INFO("Simulation time %g", MSG_get_clock());
-  return res;
-}                               /* end_of_test_all */
+  MSG_create_environment(argv[1]);
 
 
+  MSG_function_register("master", master);
+  MSG_function_register("slave", slave);
+  MSG_launch_application(argv[2]);
 
 
-/** Main function */
-int main(int argc, char *argv[])
-{
-  msg_error_t res = MSG_OK;
+  res = MSG_main();
 
 
-  MSG_init(&argc, argv);
-  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-            "\tExample: %s msg_platform.xml msg_deployment.xml\n", 
-            argv[0], argv[0]);
-  
-  res = test_all(argv[1], argv[2]);
+  XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
 }
 
   return res != MSG_OK;
 }
index 8628584..74e3858 100644 (file)
@@ -4,35 +4,21 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"        /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
-#include "xbt/sysdep.h"         /* calloc, printf */
+#include "simgrid/msg.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-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");
 
 /** @addtogroup MSG_examples
  * 
 
 /** @addtogroup MSG_examples
  * 
- *  - <b>masterslave/masterslave_forwarder.c: Master/slaves
- *    example</b>. This good old example is also very simple. Its basic
- *    version is fully commented on this page: \ref MSG_ex_master_slave,
- *    but several variants can be found in the same directory. 
+ *  - <b>masterslave/masterslave_forwarder.c: Master/slaves example</b>. This good old example is also very simple. Its
+ *    basic version is fully commented on this page: \ref MSG_ex_master_slave, but several variants can be found in the
+ *    same directory.
  */
 
  */
 
-
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
-int forwarder(int argc, char *argv[]);
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file);
-
 #define FINALIZE ((void*)221297)        /* a magic number to tell people to stop working */
 
 /** Emitter function  */
 #define FINALIZE ((void*)221297)        /* a magic number to tell people to stop working */
 
 /** Emitter function  */
-int master(int argc, char *argv[])
+static int master(int argc, char *argv[])
 {
   int slaves_count = 0;
   msg_host_t *slaves = NULL;
 {
   int slaves_count = 0;
   msg_host_t *slaves = NULL;
@@ -57,9 +43,7 @@ int master(int argc, char *argv[])
 
     for (i = 0; i < number_of_tasks; i++) {
       sprintf(sprintf_buffer, "Task_%d", i);
 
     for (i = 0; i < number_of_tasks; i++) {
       sprintf(sprintf_buffer, "Task_%d", i);
-      todo[i] =
-          MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
-                          NULL);
+      todo[i] = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
     }
   }
 
     }
   }
 
@@ -69,19 +53,16 @@ int master(int argc, char *argv[])
 
     for (i = 4; i < argc; i++) {
       slaves[i - 4] = MSG_host_by_name(argv[i]);
 
     for (i = 4; i < argc; i++) {
       slaves[i - 4] = MSG_host_by_name(argv[i]);
-      xbt_assert(slaves[i - 4] != NULL, "Unknown host %s. Stopping Now! ",
-                  argv[i]);
+      xbt_assert(slaves[i - 4] != NULL, "Unknown host %s. Stopping Now! ", argv[i]);
     }
   }
 
     }
   }
 
-  XBT_INFO("Got %d slaves and %d tasks to process", slaves_count,
-        number_of_tasks);
+  XBT_INFO("Got %d slaves and %d tasks to process", slaves_count, number_of_tasks);
   for (i = 0; i < slaves_count; i++)
     XBT_DEBUG("%s", MSG_host_get_name(slaves[i]));
 
   for (i = 0; i < number_of_tasks; i++) {
   for (i = 0; i < slaves_count; i++)
     XBT_DEBUG("%s", MSG_host_get_name(slaves[i]));
 
   for (i = 0; i < number_of_tasks; i++) {
-    XBT_INFO("Sending \"%s\" to \"%s\"",
-          todo[i]->name, MSG_host_get_name(slaves[i % slaves_count]));
+    XBT_INFO("Sending \"%s\" to \"%s\"", todo[i]->name, MSG_host_get_name(slaves[i % slaves_count]));
     if (MSG_host_self() == slaves[i % slaves_count]) {
       XBT_INFO("Hey ! It's me ! :)");
     }
     if (MSG_host_self() == slaves[i % slaves_count]) {
       XBT_INFO("Hey ! It's me ! :)");
     }
@@ -90,8 +71,7 @@ int master(int argc, char *argv[])
     XBT_INFO("Sent");
   }
 
     XBT_INFO("Sent");
   }
 
-  XBT_INFO
-      ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+  XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
   for (i = 0; i < slaves_count; i++) {
     msg_task_t finalize = MSG_task_create("finalize", 0, 0, FINALIZE);
     MSG_task_send(finalize, MSG_host_get_name(slaves[i]));
   for (i = 0; i < slaves_count; i++) {
     msg_task_t finalize = MSG_task_create("finalize", 0, 0, FINALIZE);
     MSG_task_send(finalize, MSG_host_get_name(slaves[i]));
@@ -101,10 +81,9 @@ int master(int argc, char *argv[])
   free(slaves);
   free(todo);
   return 0;
   free(slaves);
   free(todo);
   return 0;
-}                               /* end_of_master */
+}
 
 
-/** Receiver function  */
-int slave(int argc, char *argv[])
+static int slave(int argc, char *argv[])
 {
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED int res;
 {
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED int res;
@@ -126,10 +105,9 @@ int slave(int argc, char *argv[])
   }
   XBT_INFO("I'm done. See you!");
   return 0;
   }
   XBT_INFO("I'm done. See you!");
   return 0;
-}                               /* end_of_slave */
+}
 
 
-/** Forwarder function */
-int forwarder(int argc, char *argv[])
+static int forwarder(int argc, char *argv[])
 {
   int i;
   int slaves_count;
 {
   int i;
   int slaves_count;
@@ -156,16 +134,13 @@ int forwarder(int argc, char *argv[])
     if (a == MSG_OK) {
       XBT_INFO("Received \"%s\"", MSG_task_get_name(task));
       if (MSG_task_get_data(task) == FINALIZE) {
     if (a == MSG_OK) {
       XBT_INFO("Received \"%s\"", MSG_task_get_name(task));
       if (MSG_task_get_data(task) == FINALIZE) {
-        XBT_INFO
-            ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+        XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
         for (i = 0; i < slaves_count; i++)
         for (i = 0; i < slaves_count; i++)
-          MSG_task_send(MSG_task_create("finalize", 0, 0, FINALIZE),
-              MSG_host_get_name(slaves[i]));
+          MSG_task_send(MSG_task_create("finalize", 0, 0, FINALIZE), MSG_host_get_name(slaves[i]));
         MSG_task_destroy(task);
         break;
       }
         MSG_task_destroy(task);
         break;
       }
-      XBT_INFO("Sending \"%s\" to \"%s\"",
-            MSG_task_get_name(task), MSG_host_get_name(slaves[i % slaves_count]));
+      XBT_INFO("Sending \"%s\" to \"%s\"", MSG_task_get_name(task), MSG_host_get_name(slaves[i % slaves_count]));
       MSG_task_send(task, MSG_host_get_name(slaves[i % slaves_count]));
       i++;
     } else {
       MSG_task_send(task, MSG_host_get_name(slaves[i % slaves_count]));
       i++;
     } else {
@@ -177,41 +152,26 @@ int forwarder(int argc, char *argv[])
 
   XBT_INFO("I'm done. See you!");
   return 0;
 
   XBT_INFO("I'm done. See you!");
   return 0;
-}                               /* end_of_forwarder */
+}
 
 
-/** Test function */
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file)
+int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
 {
   msg_error_t res = MSG_OK;
 
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("master", master);
-    MSG_function_register("slave", slave);
-    MSG_function_register("forwarder", forwarder);
-    MSG_launch_application(application_file);
-  }
-  res = MSG_main();
+  MSG_init(&argc, argv);
+  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
+             "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
 
 
-  XBT_INFO("Simulation time %g", MSG_get_clock());
-  return res;
-}                               /* end_of_test_all */
+  MSG_create_environment(argv[1]);
 
 
+  MSG_function_register("master", master);
+  MSG_function_register("slave", slave);
+  MSG_function_register("forwarder", forwarder);
+  MSG_launch_application(argv[2]);
 
 
-/** Main function */
-int main(int argc, char *argv[])
-{
-  msg_error_t res = MSG_OK;
+  res = MSG_main();
 
 
-  MSG_init(&argc, argv);
-  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-            "\tExample: %s msg_platform.xml msg_deployment.xml\n", 
-            argv[0], argv[0]);
-  
-  res = test_all(argv[1], argv[2]);
+  XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
 }
 
   return res != MSG_OK;
 }
index 91e9914..365ebb3 100644 (file)
@@ -4,13 +4,9 @@
 /* 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. */
 
 /* 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"        /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
-#include "xbt/sysdep.h"         /* calloc */
+#include "simgrid/msg.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-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");
 
 /** Lazy guy function. This process suspends itself asap.  */
 static int slave(int argc, char *argv[])
 
 /** Lazy guy function. This process suspends itself asap.  */
 static int slave(int argc, char *argv[])
@@ -22,7 +18,7 @@ static int slave(int argc, char *argv[])
   MSG_task_execute(MSG_task_create("toto", 1e9, 0, NULL));
   XBT_INFO("Bye!");
   return 0;
   MSG_task_execute(MSG_task_create("toto", 1e9, 0, NULL));
   XBT_INFO("Bye!");
   return 0;
-}                               /* end_of_lazy_guy */
+}
 
 static int master(int argc, char *argv[])
 {
 
 static int master(int argc, char *argv[])
 {
@@ -40,37 +36,25 @@ static int master(int argc, char *argv[])
 
   XBT_INFO("OK, goodbye now.");
   return 0;
 
   XBT_INFO("OK, goodbye now.");
   return 0;
-}                               /* end_of_dram_master */
+}
 
 
-/** Test function */
-static msg_error_t test_all(const char *platform_file,
-                            const char *application_file)
+int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
 {
   msg_error_t res = MSG_OK;
 
-  MSG_create_environment(platform_file);
+  MSG_init(&argc, argv);
+  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
+             "\tExample: %s msg_platform.xml msg_deployment_suspend.xml\n", argv[0], argv[0]);
+
+  MSG_create_environment(argv[1]);
+
   MSG_function_register("master", master);
   MSG_function_register("slave", slave);
   MSG_function_register("master", master);
   MSG_function_register("slave", slave);
-  MSG_launch_application(application_file);
+  MSG_launch_application(argv[2]);
 
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
-  return res;
-}                               /* end_of_test_all */
-
-
-/** Main function */
-int main(int argc, char *argv[])
-{
-  msg_error_t res = MSG_OK;
-
-  MSG_init(&argc, argv);
-  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-            "\tExample: %s msg_platform.xml msg_deployment_suspend.xml\n", 
-            argv[0], argv[0]);
-
-  test_all(argv[1], argv[2]);
 
   return res != MSG_OK;
 }
 
   return res != MSG_OK;
 }
index 8c4c100..8aed047 100644 (file)
@@ -4,21 +4,11 @@
 /* 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. */
 
 /* 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 "simgrid/msg.h"        /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
-#include "xbt/sysdep.h"
+#include "simgrid/msg.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-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");
 
 
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
-
-/** Sender function  */
-int master(int argc, char *argv[])
+static int master(int argc, char *argv[])
 {
   long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
   double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
 {
   long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
   double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
@@ -36,18 +26,14 @@ int master(int argc, char *argv[])
 
     sprintf(mailbox, "slave-%ld", i % slaves_count);
     sprintf(sprintf_buffer, "Task_%d", i);
 
     sprintf(mailbox, "slave-%ld", i % slaves_count);
     sprintf(sprintf_buffer, "Task_%d", i);
-    task =
-        MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
-                        NULL);
+    task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
     if (number_of_tasks < 10000 || i % 10000 == 0)
     if (number_of_tasks < 10000 || i % 10000 == 0)
-      XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name,
-            number_of_tasks, mailbox);
+      XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox);
 
     MSG_task_send(task, mailbox);
   }
 
 
     MSG_task_send(task, mailbox);
   }
 
-  XBT_INFO
-      ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+  XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
   for (i = 0; i < slaves_count; i++) {
     char mailbox[80];
 
   for (i = 0; i < slaves_count; i++) {
     char mailbox[80];
 
@@ -56,12 +42,10 @@ int master(int argc, char *argv[])
     MSG_task_send(finalize, mailbox);
   }
 
     MSG_task_send(finalize, mailbox);
   }
 
-//  XBT_INFO("Goodbye now!");
   return 0;
   return 0;
-}                               /* end_of_master */
+}
 
 
-/** Receiver function  */
-int slave(int argc, char *argv[])
+static int slave(int argc, char *argv[])
 {
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED int res;
 {
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED int res;
@@ -91,32 +75,21 @@ int slave(int argc, char *argv[])
   }
   XBT_INFO("I'm done. See you!");
   return 0;
   }
   XBT_INFO("I'm done. See you!");
   return 0;
-}                               /* end_of_slave */
+}
 
 
-/** Main function */
 int main(int argc, char *argv[])
 {
 int main(int argc, char *argv[])
 {
-  msg_error_t res;
-  const char *platform_file;
-  const char *application_file;
-
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-            "\tExample: %s msg_platform.xml msg_deployment.xml\n", 
-            argv[0], argv[0]);
-  
-  platform_file = argv[1];
-  application_file = argv[2];
-
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("master", master);
-    MSG_function_register("slave", slave);
-    MSG_launch_application(application_file);
-  }
-  res = MSG_main();
+             "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
+
+  MSG_create_environment(argv[1]);
+
+  MSG_function_register("master", master);
+  MSG_function_register("slave", slave);
+  MSG_launch_application(argv[2]);
+
+  msg_error_t res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
index 9a6bd21..9fdc4a8 100644 (file)
@@ -4,20 +4,14 @@
 /* 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. */
 
 /* 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"        /* core library */
-#include "xbt/sysdep.h"         /* calloc */
-#include "xbt/synchro_core.h"
+#include "simgrid/msg.h"
 
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-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");
 
 /** @addtogroup MSG_examples
  *  
 
 /** @addtogroup MSG_examples
  *  
- *  - <b>migration/migration.c</b> Demonstrates how to use the @ref
- *    MSG_process_migrate function to let processes change the host they 
- *    run on after their start. 
+ *  - <b>migration/migration.c</b> Demonstrates how to use the @ref MSG_process_migrate function to let processes
+ *    change the host they run on after their start.
  */
 
 xbt_mutex_t mutex = NULL;
  */
 
 xbt_mutex_t mutex = NULL;
@@ -28,10 +22,9 @@ static msg_process_t process_to_migrate = NULL;
 static int emigrant(int argc, char *argv[])
 {
   msg_task_t task;
 static int emigrant(int argc, char *argv[])
 {
   msg_task_t task;
-  XBT_INFO
-      ("I'll look for a new job on another machine where the grass is greener.");
+  XBT_INFO("I'll look for a new job on another machine where the grass is greener.");
   MSG_process_migrate(MSG_process_self(), MSG_host_by_name("Boivin"));
   MSG_process_migrate(MSG_process_self(), MSG_host_by_name("Boivin"));
-  
+
   XBT_INFO("Yeah, found something to do");
   task = MSG_task_create("job", 98095000, 0, NULL);
   MSG_task_execute(task);
   XBT_INFO("Yeah, found something to do");
   task = MSG_task_create("job", 98095000, 0, NULL);
   MSG_task_execute(task);
@@ -50,13 +43,11 @@ static int emigrant(int argc, char *argv[])
   XBT_INFO("I've been moved on this new host: %s", MSG_host_get_name(h));
   XBT_INFO("Uh, nothing to do here. Stopping now");
   return 0;
   XBT_INFO("I've been moved on this new host: %s", MSG_host_get_name(h));
   XBT_INFO("Uh, nothing to do here. Stopping now");
   return 0;
-}                               /* end_of_emigrant */
-
+}
 
 /* This function move the emigrant on Jacquelin */
 static int policeman(int argc, char *argv[])
 {
 
 /* This function move the emigrant on Jacquelin */
 static int policeman(int argc, char *argv[])
 {
-
   xbt_mutex_acquire(mutex);
   XBT_INFO("Wait a bit before migrating the emigrant.");
   while (process_to_migrate == NULL) xbt_cond_wait(cond, mutex);
   xbt_mutex_acquire(mutex);
   XBT_INFO("Wait a bit before migrating the emigrant.");
   while (process_to_migrate == NULL) xbt_cond_wait(cond, mutex);
@@ -66,29 +57,22 @@ static int policeman(int argc, char *argv[])
   xbt_mutex_release(mutex);
 
   return 0;
   xbt_mutex_release(mutex);
 
   return 0;
-}                               /* end_of_policeman */
-
+}
 
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 
-  /* Argument checking */
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-            "\tExample: %s msg_platform.xml msg_deployment_suspend.xml\n", 
-            argv[0], argv[0]);
+            "\tExample: %s msg_platform.xml msg_deployment_suspend.xml\n", argv[0], argv[0]);
 
 
-  /* Simulation setting */
   MSG_create_environment(argv[1]);
 
   MSG_create_environment(argv[1]);
 
-  /* Application deployment */
   MSG_function_register("emigrant", emigrant);
   MSG_function_register("policeman", policeman);
   MSG_launch_application(argv[2]);
 
   MSG_function_register("emigrant", emigrant);
   MSG_function_register("policeman", policeman);
   MSG_launch_application(argv[2]);
 
-  /* Run the simulation */
   mutex = xbt_mutex_init();
   cond = xbt_cond_init();
   res = MSG_main();
   mutex = xbt_mutex_init();
   cond = xbt_cond_init();
   res = MSG_main();
index 42fa9d1..f2fb14b 100644 (file)
@@ -4,14 +4,9 @@
 /* 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. */
 
 /* 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 <stdlib.h>
 #include "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/asserts.h"
 
 
-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");
 
 
 /** @addtogroup MSG_examples
 
 
 /** @addtogroup MSG_examples
@@ -20,24 +15,14 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
  * 
  *  @subsection MSG_ex_PLS Packet level simulators
  * 
  * 
  *  @subsection MSG_ex_PLS Packet level simulators
  * 
- *  These examples demonstrate how to use the bindings to classical
- *  Packet-Level Simulators (PLS), as explained in \ref pls. The most
- *  interesting is probably not the C files since they are unchanged
- *  from the other simulations, but the associated files, such as the
- *  platform files to see how to declare a platform to be used with
- *  the PLS bindings of SimGrid and the tesh files to see how to
- *  actually start a simulation in these settings.
+ *  These examples demonstrate how to use the bindings to classicalPacket-Level Simulators (PLS), as explained in
+ *  \ref pls. The most interesting is probably not the C files since they are unchanged from the other simulations,
+ *  but the associated files, such as the platform files to see how to declare a platform to be used with the PLS
+ *  bindings of SimGrid and the tesh files to see how to actually start a simulation in these settings.
  * 
  * - <b>ns3</b>: Simple ping-pong using ns3 instead of the SimGrid network models. 
  * 
  * - <b>ns3</b>: Simple ping-pong using ns3 instead of the SimGrid network models. 
- * 
  */
 
  */
 
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
-int timer(int argc, char *argv[]);
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file);
-
 int timer_start; //set as 1 in the master process
 
 //keep a pointer to all surf running tasks.
 int timer_start; //set as 1 in the master process
 
 //keep a pointer to all surf running tasks.
@@ -53,8 +38,7 @@ int count_finished = 0;
 
 #define FINALIZE ((void*)221297)        /* a magic number to tell people to stop working */
 
 
 #define FINALIZE ((void*)221297)        /* a magic number to tell people to stop working */
 
-/** master */
-int master(int argc, char *argv[])
+static int master(int argc, char *argv[])
 {
   msg_task_t todo;
 
 {
   msg_task_t todo;
 
@@ -82,9 +66,7 @@ int master(int argc, char *argv[])
     gl_data_size[id] = task_comm_size;
   }
 
     gl_data_size[id] = task_comm_size;
   }
 
-  {                             /* Process organization */
-    MSG_host_by_name(slavename);
-  }
+  MSG_host_by_name(slavename);
 
   count_finished++;
   timer_start = 1 ;
 
   count_finished++;
   timer_start = 1 ;
@@ -98,10 +80,8 @@ int master(int argc, char *argv[])
   XBT_DEBUG ("Finished");
   xbt_free(id_alias);
   return 0;
   XBT_DEBUG ("Finished");
   xbt_free(id_alias);
   return 0;
-}                               /* end_of_master */
-
+}
 
 
-/** Timer function  */
 int timer(int argc, char *argv[])
 {
   double sleep_time;
 int timer(int argc, char *argv[])
 {
   double sleep_time;
@@ -120,81 +100,48 @@ int timer(int argc, char *argv[])
 
   do {
     XBT_DEBUG ("Get sleep");
 
   do {
     XBT_DEBUG ("Get sleep");
-      MSG_process_sleep(sleep_time);
+    MSG_process_sleep(sleep_time);
   } while(timer_start);
 
   XBT_DEBUG ("Finished");
   return 0;
 }
 
   } while(timer_start);
 
   XBT_DEBUG ("Finished");
   return 0;
 }
 
-/** Receiver function  */
-int slave(int argc, char *argv[])
+static int slave(int argc, char *argv[])
 {
 {
-
   msg_task_t task = NULL;
   msg_task_t task = NULL;
-  int a = MSG_OK;
-  int id = 0;
   char id_alias[10];
 
   xbt_assert(argc==2,"Strange number of arguments expected 1 got %d", argc - 1);
 
   XBT_DEBUG ("Slave started");
 
   char id_alias[10];
 
   xbt_assert(argc==2,"Strange number of arguments expected 1 got %d", argc - 1);
 
   XBT_DEBUG ("Slave started");
 
-  id = xbt_str_parse_int(argv[1], "Invalid id: %s");
+  int id = xbt_str_parse_int(argv[1], "Invalid id: %s");
   sprintf(id_alias, "%d", id);
 
   sprintf(id_alias, "%d", id);
 
-  a = MSG_task_receive(&(task), id_alias);
+  msg_error_t a = MSG_task_receive(&(task), id_alias);
 
   count_finished--;
   if(count_finished == 0){
       timer_start = 0;
   }
 
 
   count_finished--;
   if(count_finished == 0){
       timer_start = 0;
   }
 
-
-
   if (a != MSG_OK) {
     XBT_INFO("Hey?! What's up?");
     xbt_die("Unexpected behavior.");
   }
 
   elapsed_time = MSG_get_clock() - start_time;
   if (a != MSG_OK) {
     XBT_INFO("Hey?! What's up?");
     xbt_die("Unexpected behavior.");
   }
 
   elapsed_time = MSG_get_clock() - start_time;
-  
-  XBT_INFO("FLOW[%d] : Receive %.0f bytes from %s to %s",
-      id,
-      MSG_task_get_bytes_amount(task),
-       masternames[id],
-       slavenames[id]);
+
+  XBT_INFO("FLOW[%d] : Receive %.0f bytes from %s to %s", id, MSG_task_get_bytes_amount(task), masternames[id],
+           slavenames[id]);
 //  MSG_task_execute(task);
   MSG_task_destroy(task);
 
   XBT_DEBUG ("Finished");
   return 0;
 //  MSG_task_execute(task);
   MSG_task_destroy(task);
 
   XBT_DEBUG ("Finished");
   return 0;
-}                               /* end_of_slave */
-
-/** Test function */
-msg_error_t test_all(const char *platform_file,
-                     const char *application_file)
-{
-  msg_error_t res = MSG_OK;
-
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-
-  TRACE_declare_mark("endmark");
-
-  {                             /*   Application deployment */
-    MSG_function_register("master", master);
-    MSG_function_register("slave", slave);
-    MSG_function_register("timer", timer);
-
-    MSG_launch_application(application_file);
-  }
-  res = MSG_main();
-  return res;
-}                               /* end_of_test_all */
+}
 
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
 int main(int argc, char *argv[])
 {
   msg_error_t res = MSG_OK;
@@ -202,11 +149,18 @@ int main(int argc, char *argv[])
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
 
   MSG_init(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-            "\tExample: %s platform.xml deployment.xml\n", 
-            argv[0], argv[0]);
-   
+             "\tExample: %s platform.xml deployment.xml\n", argv[0], argv[0]);
+
+  MSG_create_environment(argv[1]);
+  TRACE_declare_mark("endmark");
 
 
-  res = test_all(argv[1], argv[2]);
+  MSG_function_register("master", master);
+  MSG_function_register("slave", slave);
+  MSG_function_register("timer", timer);
+
+  MSG_launch_application(argv[2]);
+
+  res = MSG_main();
 
   return res != MSG_OK;
 }
 
   return res != MSG_OK;
 }
index e291efd..3308119 100644 (file)
@@ -16,7 +16,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example")
  *   interfaces, but it's not possible ATM).
  */
 
  *   interfaces, but it's not possible ATM).
  */
 
-
 static int runner(int argc, char *argv[])
 {
   /* Retrieve the list of all hosts as an array of hosts */
 static int runner(int argc, char *argv[])
 {
   /* Retrieve the list of all hosts as an array of hosts */
@@ -24,7 +23,8 @@ static int runner(int argc, char *argv[])
   int slaves_count = xbt_dynar_length(slaves_dynar);
   msg_host_t *slaves = xbt_dynar_to_array(slaves_dynar);
 
   int slaves_count = xbt_dynar_length(slaves_dynar);
   msg_host_t *slaves = xbt_dynar_to_array(slaves_dynar);
 
-  XBT_INFO("First, build a classical parallel task, with 1 Gflop to execute on each node, and 10MB to exchange between each pair");
+  XBT_INFO("First, build a classical parallel task, with 1 Gflop to execute on each node, "
+           "and 10MB to exchange between each pair");
   double *computation_amounts = xbt_new0(double, slaves_count);
   double *communication_amounts = xbt_new0(double, slaves_count * slaves_count);
 
   double *computation_amounts = xbt_new0(double, slaves_count);
   double *communication_amounts = xbt_new0(double, slaves_count * slaves_count);
 
index 37d443c..2b6efe9 100644 (file)
@@ -4,14 +4,10 @@
 /* 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. */
 
 /* 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 <math.h>
 #include "simgrid/msg.h"
 #include <math.h>
 #include "simgrid/msg.h"
-#include "xbt/log.h"
-#include "xbt/asserts.h"
 
 
- XBT_LOG_NEW_DEFAULT_CATEGORY(msg_pastry,
-                             "Messages specific for this msg example");
+ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_pastry, "Messages specific for this msg example");
 
 /***************************************
  * PASTRY                              *
 
 /***************************************
  * PASTRY                              *
@@ -40,7 +36,6 @@ static int max_simulation_time = 1000;
 
 extern long int smx_total_comms;
 
 
 extern long int smx_total_comms;
 
-
 typedef struct s_node {
   int id;                                 //128bits generated random(2^128 -1)
   int known_id;
 typedef struct s_node {
   int id;                                 //128bits generated random(2^128 -1)
   int known_id;
@@ -60,9 +55,7 @@ typedef struct s_state {
   int routing_table[LEVELS_COUNT][LEVEL_SIZE];
 } s_state_t, *state_t;
 
   int routing_table[LEVELS_COUNT][LEVEL_SIZE];
 } s_state_t, *state_t;
 
-/**
- * Types of tasks exchanged between nodes.
- */
+/** Types of tasks exchanged between nodes. */
 typedef enum {
   TASK_JOIN,
   TASK_JOIN_REPLY,
 typedef enum {
   TASK_JOIN,
   TASK_JOIN_REPLY,
@@ -96,7 +89,6 @@ static int routing_next(node_t node, int dest);
 static void create(node_t node);
 static int join(node_t node);
 
 static void create(node_t node);
 static int join(node_t node);
 
-
 /**
  * \brief Gets the mailbox name of a host given its chord id.
  * \param node_id id of a node
 /**
  * \brief Gets the mailbox name of a host given its chord id.
  * \param node_id id of a node
index c9ef867..5d4f662 100644 (file)
@@ -8,7 +8,6 @@
 
 #include "simgrid/msg.h"
 #include "xbt/matrix.h"
 
 #include "simgrid/msg.h"
 #include "xbt/matrix.h"
-#include "xbt/log.h"
 #include "xbt/xbt_os_time.h"
 
 /** @addtogroup MSG_examples
 #include "xbt/xbt_os_time.h"
 
 /** @addtogroup MSG_examples
index 7fab442..9d4e0a9 100644 (file)
@@ -4,9 +4,7 @@
 /* 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. */
 
 /* 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 <stdlib.h>
 #include "simgrid/msg.h"
 #include "simgrid/msg.h"
-#include "xbt/log.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_semaphore_example, "Messages specific for this msg example");
 
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_semaphore_example, "Messages specific for this msg example");
 
index 820cc7e..0de9b4a 100644 (file)
@@ -17,7 +17,7 @@ static int sleeper(int argc, char *argv[])
 {
   XBT_INFO("Hello! I go to sleep.");
   MSG_process_on_exit(my_onexit, NULL);
 {
   XBT_INFO("Hello! I go to sleep.");
   MSG_process_on_exit(my_onexit, NULL);
-   
+
   MSG_process_sleep(xbt_str_parse_int(argv[1], "sleeper process expects an integer parameter but got %s"));
   XBT_INFO("Done sleeping.");
   return 0;
   MSG_process_sleep(xbt_str_parse_int(argv[1], "sleeper process expects an integer parameter but got %s"));
   XBT_INFO("Done sleeping.");
   return 0;