-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved. */
/* 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. */
xbt_dynar_t pending_tasks;
} s_node_t;
typedef s_node_t* node_t;
+typedef const s_node_t* const_node_t;
typedef struct s_state {
int id;
} s_task_data_t;
typedef s_task_data_t* task_data_t;
-static int domain(unsigned int a, unsigned int level);
-static int shl(int a, int b);
-static int closest_in_namespace_set(node_t node, int dest);
-static int routing_next(node_t node, int dest);
-
/**
* @brief Gets the mailbox name of a host given its chord id.
* @param node_id id of a node
}
/* Get the closest id to the dest in the node namespace_set */
-static int closest_in_namespace_set(node_t node, int dest) {
+static int closest_in_namespace_set(const_node_t node, int dest)
+{
int res = -1;
if ((node->namespace_set[NAMESPACE_SIZE-1] <= dest) && (dest <= node->namespace_set[0])) {
int best_dist = abs(node->id - dest);
}
/* Find the next node to forward a message to */
-static int routing_next(node_t node, int dest) {
+static int routing_next(const_node_t node, int dest)
+{
int closest = closest_in_namespace_set(node, dest);
if (closest!=-1)
return closest;
}
/* Get the corresponding state of a node */
-static state_t node_get_state(node_t node) {
+static state_t node_get_state(const_node_t node)
+{
state_t state = xbt_new0(s_state_t,1);
state->id = node->id;
for (int i=0; i<NEIGHBORHOOD_SIZE; i++)
return state;
}
-static void print_node_id(node_t node) {
+static void print_node_id(const_node_t node)
+{
XBT_INFO(" Id: %i '%08x' ", node->id, (unsigned)node->id);
}
-static void print_node_neighborood_set(node_t node) {
+static void print_node_neighborood_set(const_node_t node)
+{
XBT_INFO(" Neighborhood:");
for (int i=0; i<NEIGHBORHOOD_SIZE; i++)
XBT_INFO(" %08x", (unsigned)node->neighborhood_set[i]);
}
-static void print_node_routing_table(node_t node) {
+static void print_node_routing_table(const_node_t node)
+{
XBT_INFO(" Routing table:");
for (int i=0; i<LEVELS_COUNT; i++){
for (int j=0; j<LEVEL_SIZE; j++)
}
}
/* Print the node namespace set */
-static void print_node_namespace_set(node_t node) {
+static void print_node_namespace_set(const_node_t node)
+{
XBT_INFO(" Namespace:");
for (int i=0; i<NAMESPACE_SIZE; i++)
XBT_INFO(" %08x", (unsigned)node->namespace_set[i]);
}
/* Print the node information */
-static void print_node(node_t node) {
+static void print_node(const_node_t node)
+{
XBT_INFO("Node:");
print_node_id(node);
print_node_neighborood_set(node);
}
/* Join the ring */
-static int join(node_t node){
+static int join(const_node_t node)
+{
task_data_t req_data = xbt_new0(s_task_data_t,1);
req_data->type = TASK_JOIN;
req_data->sender_id = node->id;