Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Compute the real simulation time.
[simgrid.git] / examples / msg / chord / chord.c
index 2ca3ac6..773fb4b 100644 (file)
@@ -11,6 +11,8 @@
 #include "xbt/asserts.h"
 #include "mc/modelchecker.h"
 #include "mc/mc.h"
+#include "xbt/xbt_os_time.h"
+
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chord,
                              "Messages specific for this msg example");
 
@@ -27,6 +29,8 @@ static int periodic_fix_fingers_delay = 120;
 static int periodic_check_predecessor_delay = 120;
 static int periodic_lookup_delay = 10;
 
+extern long int smx_total_comms;
+
 /**
  * Finger element.
  */
@@ -390,6 +394,7 @@ int node(int argc, char *argv[])
 
   // stop the simulation
   xbt_free(node.fingers);
+  INFO1("Messages created: %lu", smx_total_comms);
   return 0;
 }
 
@@ -502,6 +507,11 @@ static int join(node_t node, int known_id)
   INFO2("Joining the ring with id %d, knowing node %d", node->id, known_id);
   set_predecessor(node, -1); // no predecessor (yet)
 
+  int i;
+  for (i = 0; i < nb_bits; i++) {
+    set_finger(node, i, known_id);
+  }
+
   int successor_id = remote_find_successor(node, known_id, node->id);
   if (successor_id == -1) {
     INFO0("Cannot join the ring.");
@@ -879,6 +889,8 @@ static void random_lookup(node_t node)
  */
 int main(int argc, char *argv[])
 {
+  xbt_os_timer_t timer = xbt_os_timer_new();
+
   if (argc < 3) {
     printf("Usage: %s [-nb_bits=n] [-timeout=t] platform_file deployment_file\n", argv[0]);
     printf("example: %s ../msg_platform.xml chord.xml\n", argv[0]);
@@ -920,8 +932,11 @@ int main(int argc, char *argv[])
   MSG_function_register("node", node);
   MSG_launch_application(application_file);
 
+  xbt_os_timer_start(timer);
   MSG_error_t res = MSG_main();
-  INFO1("Simulation time: %g", MSG_get_clock());
+  xbt_os_timer_stop(timer);
+  CRITICAL1("Simulation time %lf", xbt_os_timer_elapsed(timer));
+  INFO1("Simulated time: %g", MSG_get_clock());
 
   MSG_clean();