X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0aef0fac11f6ca97d59a6ff5e5123fa18e28629c..13fb4af932a02ea0bd4293d1e55ac071de326f80:/examples/msg/dht-chord/dht-chord.c diff --git a/examples/msg/dht-chord/dht-chord.c b/examples/msg/dht-chord/dht-chord.c index bb59f78943..88096d24ba 100644 --- a/examples/msg/dht-chord/dht-chord.c +++ b/examples/msg/dht-chord/dht-chord.c @@ -43,7 +43,7 @@ static void chord_initialize(void) RngStream stream; snprintf(descr, sizeof descr, "RngSream<%s>", MSG_host_get_name(host)); stream = RngStream_CreateStream(descr); - MSG_host_set_property_value(host, "stream", (char*)stream, NULL); + MSG_host_set_data(host, stream); } } @@ -52,8 +52,9 @@ static void chord_exit(void) msg_host_t host; unsigned i; xbt_dynar_foreach(host_list, i, host) { - RngStream stream = (RngStream)MSG_host_get_property_value(host, "stream"); + RngStream stream = (RngStream)MSG_host_get_data(host); RngStream_DeleteStream(&stream); + MSG_host_set_data(host, NULL); } xbt_dynar_free(&host_list); @@ -133,7 +134,7 @@ static void print_finger_table(node_t node) } /* Sets a finger of the current node. - * + * * \param node the current node * \param finger_index index of the finger to set (0 to nb_bits - 1) * \param id the id to set for this finger @@ -149,7 +150,7 @@ static void set_finger(node_t node, int finger_index, int id) } /* Sets the predecessor of the current node. - * + * * \param node the current node * \param id the id to predecessor, or -1 to unset the predecessor */ @@ -168,14 +169,14 @@ static void set_predecessor(node_t node, int predecessor_id) } /* Node main Function - * + * * Arguments: * - my id * - the id of a guy I know in the system (except for the first node) * - the time to sleep before I join (except for the first node) */ /* This function is called when the current node receives a task. - * + * * \param node the current node * \param task the task to handle (don't touch it afterward: it will be destroyed, reused or forwarded) */ @@ -275,7 +276,7 @@ void create(node_t node) } /* Makes the current node join the ring, knowing the id of a node already in the ring - * + * * \param node the current node * \param known_id id of a node already in the ring * \return 1 if the join operation succeeded, 0 otherwise @@ -326,7 +327,6 @@ void quit_notify(node_t node) get_mailbox(node->pred_id, mailbox); task_data_t req_data_s = xbt_new0(s_task_data_t,1); req_data_s->type = TASK_SUCCESSOR_LEAVING; - req_data_s->request_id = node->fingers[0].id; req_data_s->request_id = node->pred_id; get_mailbox(node->id, req_data_s->answer_to); req_data_s->issuer_host_name = MSG_host_get_name(MSG_host_self()); @@ -340,7 +340,7 @@ void quit_notify(node_t node) } /* Makes the current node find the successor node of an id. - * + * * \param node the current node * \param id the id to find * \return the id of the successor node, or -1 if the request failed @@ -358,7 +358,7 @@ int find_successor(node_t node, int id) } /* \brief Asks another node the successor node of an id. - * + * * \param node the current node * \param ask_to the node to ask to * \param id the id to find @@ -418,9 +418,9 @@ int remote_find_successor(node_t node, int ask_to, int id) // } // That explained the bug in a snap, with a very cool example and everything. // - // This MC_assert is now desactivated as the case is now properly handled in our code and we don't want the + // This MC_assert is now deactivated as the case is now properly handled in our code and we don't want the // MC to fail any further under that condition, but this comment is here to as a memorial for this first - // brillant victory of the model-checking in the SimGrid community :) + // brilliant victory of the model-checking in the SimGrid community :) if (task_received != task_sent || ans_data->type != TASK_FIND_SUCCESSOR_ANSWER) { @@ -447,7 +447,7 @@ int remote_find_successor(node_t node, int ask_to, int id) } /* Asks its predecessor to a remote node - * + * * \param node the current node * \param ask_to the node to ask to * \return the id of its predecessor node, or -1 if the request failed @@ -526,7 +526,7 @@ int remote_get_predecessor(node_t node, int ask_to) } /* Returns the closest preceding finger of an id with respect to the finger table of the current node. - * + * * \param node the current node * \param id the id to find * \return the closest preceding finger of that id @@ -563,7 +563,7 @@ void stabilize(node_t node) set_finger(node, 0, candidate_id); } if (successor_id != node->id) { - remote_notify(node, successor_id, node->id); + remote_notify(successor_id, node->id); } } @@ -582,7 +582,7 @@ void notify(node_t node, int predecessor_candidate_id) { } /* Notifies a remote node that its predecessor may have changed. */ -void remote_notify(node_t node, int notify_id, int predecessor_candidate_id) { +void remote_notify(int notify_id, int predecessor_candidate_id) { task_data_t req_data = xbt_new0(s_task_data_t, 1); req_data->type = TASK_NOTIFY; @@ -712,7 +712,7 @@ static int node(int argc, char *argv[]) // initialize my node s_node_t node = {0}; node.id = xbt_str_parse_int(argv[1],"Invalid ID: %s"); - node.stream = (RngStream)MSG_host_get_property_value(MSG_host_self(), "stream"); + node.stream = (RngStream)MSG_host_get_data(MSG_host_self()); get_mailbox(node.id, node.mailbox); node.next_finger_to_fix = 0; node.fingers = xbt_new0(s_finger_t, nb_bits); @@ -738,8 +738,9 @@ static int node(int argc, char *argv[]) if (join_success) { double now = MSG_get_clock(); + int listen = 0; + int no_op = 0; while (now < init_time + deadline && now < max_simulation_time) { - if (node.comm_receive == NULL) { task_received = NULL; node.comm_receive = MSG_task_irecv(&task_received, node.mailbox); @@ -748,8 +749,6 @@ static int node(int argc, char *argv[]) if (!MSG_comm_test(node.comm_receive)) { // no task was received: make some periodic calls if(MC_is_active() || MC_record_replay_is_active()){ - int listen = 0; - int no_op = 0; int sub_protocol = MC_random(0, 4); if(MC_is_active() && !MC_visited_reduction() && no_op) MC_cut();