From 7bd8c84bc04a9461ea3d4d0e98e7c122ea35af81 Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Wed, 21 Feb 2024 14:29:24 -0800 Subject: [PATCH 1/5] Added comment --- core/threaded/reactor_threaded.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/threaded/reactor_threaded.c b/core/threaded/reactor_threaded.c index 5d6e89c2a..09defbdbb 100644 --- a/core/threaded/reactor_threaded.c +++ b/core/threaded/reactor_threaded.c @@ -631,6 +631,8 @@ void _lf_initialize_start_tag(environment_t *env) { LF_PRINT_LOG("Waiting for start time " PRINTF_TIME " plus STA " PRINTF_TIME ".", start_time, lf_fed_STA_offset); #else + // For other than federated decentralized execution, there is no lf_fed_STA_offset variable defined. + // To use uniform code below, we define it here as a local variable. instant_t lf_fed_STA_offset = 0; LF_PRINT_LOG("Waiting for start time " PRINTF_TIME ".", start_time); From 151d546f35d2d299002b6f650024f45983daabe0 Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Sat, 2 Mar 2024 09:06:45 -0800 Subject: [PATCH 2/5] Comments only --- core/federated/RTI/rti_common.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/federated/RTI/rti_common.h b/core/federated/RTI/rti_common.h index 770918d5b..541be8050 100644 --- a/core/federated/RTI/rti_common.h +++ b/core/federated/RTI/rti_common.h @@ -185,9 +185,10 @@ void notify_advance_grant_if_safe(scheduling_node_t* e); void notify_provisional_tag_advance_grant(scheduling_node_t* e, tag_t tag); /** - * Determine whether the specified scheduling node is eligible for a tag advance grant, - * (TAG) and, if so, return the details. This is called upon receiving a LTC, NET - * or resign from an upstream node. + * @brief Determine whether the specified scheduling node is eligible for a tag advance grant, + * (TAG) and, if so, return the details. + * + * This is called upon receiving a LTC, NET or resign from an upstream node. * * This function calculates the minimum M over * all upstream scheduling nodes of the "after" delay plus the most recently From bf46a47ea936a6eacb6261fea1e2bc6f989a2969 Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Sat, 2 Mar 2024 09:07:14 -0800 Subject: [PATCH 3/5] More info in error message --- core/federated/federate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/federated/federate.c b/core/federated/federate.c index 290433851..512466dc6 100644 --- a/core/federated/federate.c +++ b/core/federated/federate.c @@ -2708,8 +2708,8 @@ int lf_send_tagged_message(environment_t* env, if (message_type == MSG_TYPE_P2P_TAGGED_MESSAGE) { lf_print_warning("Failed to send message to %s. Dropping the message.", next_destination_str); } else { - lf_print_error_system_failure("Failed to send message to %s. Connection lost to the RTI.", - next_destination_str); + lf_print_error_system_failure("Failed to send message to %s with error code %d (%s). Connection lost to the RTI.", + next_destination_str, errno, strerror(errno)); } } LF_MUTEX_UNLOCK(&lf_outbound_socket_mutex); From 844c90ae22caf4c4c9b0ec8cd592d3875ceea067 Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Sat, 2 Mar 2024 09:08:17 -0800 Subject: [PATCH 4/5] Use SI units in human readable time --- core/tag.c | 30 ++++++++++++++++-------------- include/core/tag.h | 13 +++++++------ 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/core/tag.c b/core/tag.c index e236dd766..3037b5990 100644 --- a/core/tag.c +++ b/core/tag.c @@ -122,6 +122,10 @@ instant_t lf_time_start(void) { } size_t lf_readable_time(char* buffer, instant_t time) { + if (time <= (instant_t)0) { + snprintf(buffer, 2, "0"); + return 1; + } char* original_buffer = buffer; bool lead = false; // Set to true when first clause has been printed. if (time > WEEKS(1)) { @@ -141,8 +145,8 @@ size_t lf_readable_time(char* buffer, instant_t time) { size_t printed = lf_comma_separated_time(buffer, time / DAYS(1)); time = time % DAYS(1); buffer += printed; - snprintf(buffer, 6, " days"); - buffer += 5; + snprintf(buffer, 3, " d"); + buffer += 2; } if (time > HOURS(1)) { if (lead == true) { @@ -153,8 +157,8 @@ size_t lf_readable_time(char* buffer, instant_t time) { size_t printed = lf_comma_separated_time(buffer, time / HOURS(1)); time = time % HOURS(1); buffer += printed; - snprintf(buffer, 7, " hours"); - buffer += 6; + snprintf(buffer, 4, " hr"); + buffer += 3; } if (time > MINUTES(1)) { if (lead == true) { @@ -165,8 +169,8 @@ size_t lf_readable_time(char* buffer, instant_t time) { size_t printed = lf_comma_separated_time(buffer, time / MINUTES(1)); time = time % MINUTES(1); buffer += printed; - snprintf(buffer, 9, " minutes"); - buffer += 8; + snprintf(buffer, 5, " min"); + buffer += 4; } if (time > SECONDS(1)) { if (lead == true) { @@ -177,28 +181,26 @@ size_t lf_readable_time(char* buffer, instant_t time) { size_t printed = lf_comma_separated_time(buffer, time / SECONDS(1)); time = time % SECONDS(1); buffer += printed; - snprintf(buffer, 9, " seconds"); - buffer += 8; + snprintf(buffer, 3, " s"); + buffer += 2; } if (time > (instant_t)0) { if (lead == true) { snprintf(buffer, 3, ", "); buffer += 2; } - const char* units = "nanoseconds"; + const char* units = "ns"; if (time % MSEC(1) == (instant_t) 0) { - units = "milliseconds"; + units = "ms"; time = time / MSEC(1); } else if (time % USEC(1) == (instant_t) 0) { - units = "microseconds"; + units = "us"; time = time / USEC(1); } size_t printed = lf_comma_separated_time(buffer, time); buffer += printed; - snprintf(buffer, 14, " %s", units); + snprintf(buffer, 3, " %s", units); buffer += strlen(units) + 1; - } else { - snprintf(buffer, 2, "0"); } return (buffer - original_buffer); } diff --git a/include/core/tag.h b/include/core/tag.h index 55d83c35d..4f2dbd031 100644 --- a/include/core/tag.h +++ b/include/core/tag.h @@ -199,21 +199,22 @@ instant_t lf_time_start(void); * Maximum number of nanoseconds is 999,999,999 * Maximum number of microsteps is 4,294,967,295 * Total number of characters for the above is 24. - * Text descriptions and spaces add an additional 55, - * for a total of 79. One more allows for a null terminator. + * Text descriptions and spaces add an additional 30, + * for a total of 54. One more allows for a null terminator. + * Round up to a power of two. */ -#define LF_TIME_BUFFER_LENGTH 80 +#define LF_TIME_BUFFER_LENGTH 64 /** * Store into the specified buffer a string giving a human-readable * rendition of the specified time. The buffer must have length at least * equal to LF_TIME_BUFFER_LENGTH. The format is: * ``` - * x weeks, x days, x hours, x minutes, x seconds, x unit + * x weeks, x d, x hr, x min, x s, x unit * ``` * where each `x` is a string of numbers with commas inserted if needed - * every three numbers and `unit` is nanoseconds, microseconds, or - * milliseconds. + * every three numbers and `unit` is ns, us, or + * ms. * @param buffer The buffer into which to write the string. * @param time The time to write. * @return The number of characters written (not counting the null terminator). From 6a8c1793d334da97725b96e691e7543778274678 Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Sat, 2 Mar 2024 16:08:03 -0800 Subject: [PATCH 5/5] Response to review --- core/tag.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/tag.c b/core/tag.c index b99546356..db590470a 100644 --- a/core/tag.c +++ b/core/tag.c @@ -157,8 +157,8 @@ size_t lf_readable_time(char* buffer, instant_t time) { size_t printed = lf_comma_separated_time(buffer, time / HOURS(1)); time = time % HOURS(1); buffer += printed; - snprintf(buffer, 4, " hr"); - buffer += 3; + snprintf(buffer, 3, " h"); + buffer += 2; } if (time > MINUTES(1)) { if (lead == true) {