Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
processes are now started in file order
[simgrid.git] / examples / gras / tokenS / tokenS.c
index 4e99a3b..1ed6e06 100644 (file)
@@ -11,7 +11,8 @@
  
 #include "gras.h"
  
-#define NBLOOPS 100
+#define NBLOOPS 3
+/*#define NBLOOPS 30000*/
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(Token,"Messages specific to this example");
 
@@ -38,14 +39,14 @@ typedef struct {
 
 
 /* Callback function */
-static int node_cb_stoken_handler(gras_socket_t  expeditor,
-                                 void          *payload_data) {
+static int node_cb_stoken_handler(gras_msg_cb_ctx_t ctx, void *payload) {
   
   xbt_ex_t e;
   
-  /* 1. Get the payload into the msg variable */
-  int msg=*(int*)payload_data;
+  /* 1. Get the payload into the msg variable, and retrieve my caller */
+  int msg=*(int*)payload;
+  gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
+
 
   /* 2. Retrieve the node's state (globals) */
   node_data_t *globals=(node_data_t*)gras_userdata_get();
@@ -56,7 +57,9 @@ static int node_cb_stoken_handler(gras_socket_t  expeditor,
     supersteps = 100;
   } else if (NBLOOPS >= 100) {
     supersteps = 10;
-  } 
+  } else if (NBLOOPS <=10) {
+    supersteps = 1;
+  }
   if (globals->create && (! (globals->remaining_loop % supersteps))) {
     INFO1("Begin a new loop. Still to do: %d", globals->remaining_loop);
   } else if (! (globals->remaining_loop % supersteps)) {
@@ -134,7 +137,8 @@ int node (int argc,char *argv[]) {
   globals->remaining_loop=NBLOOPS;
   globals->create = 0;
   globals->tosuccessor = NULL;
-       
+
+  if (!gras_os_getpid() % 100)
   INFO4("Launch node %d (successor on %s:%d; listening on %d)",
        gras_os_getpid(), host,peerport, myport);
 
@@ -142,7 +146,6 @@ int node (int argc,char *argv[]) {
   globals->sock = gras_socket_server(myport);
   gras_os_sleep(1.0); /* Make sure all server sockets are created */
 
-
   /* 5. Create socket to the successor on the ring */
   DEBUG2("Connect to my successor on %s:%d",host,peerport);