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 03a7279..1ed6e06 100644 (file)
@@ -11,7 +11,7 @@
  
 #include "gras.h"
  
-#define NBLOOPS 100
+#define NBLOOPS 3
 /*#define NBLOOPS 30000*/
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(Token,"Messages specific to this example");
@@ -39,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();
@@ -137,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);
 
@@ -145,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);