/* 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 "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
/** @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
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;
-/*
- * 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)
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,
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)
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 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
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;
}
-/**
- * \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"
- "\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)) {