Skip to content

Commit

Permalink
Add some comments and remove a FIXME
Browse files Browse the repository at this point in the history
  • Loading branch information
byeonggiljun committed Aug 14, 2024
1 parent fc970bb commit a2ab5bc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions core/federated/RTI/rti_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ tag_t get_DNET_candidate(tag_t received_tag, tag_t minimum_delay) {
return result;
}

// FIXME: It should be static because it's used only in this file. Remove from the header file.
void downstream_next_event_tag_if_needed(scheduling_node_t* node, uint16_t new_NET_source_federate_id) {
if (is_in_zero_delay_cycle(node)) {
return;
Expand Down Expand Up @@ -526,7 +525,8 @@ void downstream_next_event_tag_if_needed(scheduling_node_t* node, uint16_t new_N
}
}
if (DNET.time < start_time) {
// DNET is NEVER.
// DNET with the time smaller than the start time acts as the same as DNET of the NEVER tag.
// Thus, set DNET as NEVER_TAG to prevent sending unnecessary DNETs.
DNET = NEVER_TAG;
}

Expand Down
9 changes: 6 additions & 3 deletions core/federated/RTI/rti_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ void update_min_delays_upstream(scheduling_node_t* node);
void update_all_downstreams(scheduling_node_t* node);

/**
* Subtract the tag a from the tag b.
* Find the tag g that is the latest tag that satisfies lf_tag_add(g, minimum_delay) < received_tag.
* This function behaves like the tag subtraction, received_tag - minimum_delay.
* minimum_delay cannot be NEVER.
* @param received_tag
* @param minimum_delay
Expand All @@ -300,8 +301,10 @@ tag_t get_DNET_candidate(tag_t received_tag, tag_t minimum_delay);
void notify_downstream_next_event_tag(scheduling_node_t* e, tag_t tag);

/**
* @param node
* @param new_NET
* @param node The target node that may receive a new DNET.
* @param new_NET_source_federate_id The ID of the federate that sends a new NET. If this federate's new NET does not
* change the DNET value, we can exit this function immediately. If it does, we have to look up the target federate's
* downstream federates to compute the exact new DNET value.
*/
void downstream_next_event_tag_if_needed(scheduling_node_t* node, uint16_t new_NET_source_federate_id);

Expand Down
7 changes: 4 additions & 3 deletions core/federated/federate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,6 @@ static void handle_stop_request_message() {

/**
* Handle a downstream next event tag (DNET) message from the RTI.
* FIXME: Use this tag to eliminate unncessary LTC or NET messages.
*/
static void handle_downstream_next_event_tag() {
size_t bytes_to_read = sizeof(instant_t) + sizeof(microstep_t);
Expand Down Expand Up @@ -2412,7 +2411,9 @@ tag_t lf_send_next_event_tag(environment_t* env, tag_t tag, bool wait_for_reply)
send_tag(MSG_TYPE_NEXT_EVENT_TAG, tag);
_fed.last_sent_NET = tag;
_fed.last_skipped_NET = NEVER_TAG;
LF_PRINT_LOG("Sent next event tag (NET) " PRINTF_TAG " to RTI.", tag.time - start_time, tag.microstep);
LF_PRINT_LOG("Sent the last skipped next event tag (NET) " PRINTF_TAG
" to RTI based on the last DNET " PRINTF_TAG ".",
_fed.last_DNET - start_time, _fed.last_DNET.microstep, tag.time - start_time, tag.microstep);
}
return _fed.last_TAG;
}
Expand Down Expand Up @@ -2442,7 +2443,7 @@ tag_t lf_send_next_event_tag(environment_t* env, tag_t tag, bool wait_for_reply)
LF_PRINT_LOG("Sent next event tag (NET) " PRINTF_TAG " to RTI.", tag.time - start_time, tag.microstep);
} else {
_fed.last_skipped_NET = tag;
LF_PRINT_LOG("Skip next event tag (NET) " PRINTF_TAG " to RTI.", tag.time - start_time, tag.microstep);
LF_PRINT_LOG("Skip sending next event tag (NET) " PRINTF_TAG " to RTI.", tag.time - start_time, tag.microstep);
}

if (!wait_for_reply) {
Expand Down
6 changes: 3 additions & 3 deletions include/core/federated/federate.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,17 @@ typedef struct federate_instance_t {
tag_t last_sent_LTC;

/**
* A record of the most recently sent NET (next event tag) message.
* A record of the most recently sent NET (next event tag) signal.
*/
tag_t last_sent_NET;

/**
* A record of the most recently skipped NET (next event tag) message.
* A record of the most recently skipped NET (next event tag) signal.
*/
tag_t last_skipped_NET;

/**
*
* A record of the most recent DNET (downstream next event tag) signal.
*/
tag_t last_DNET;

Expand Down

0 comments on commit a2ab5bc

Please sign in to comment.