From 22d49a13f4c95b864fa5740f1cb6826e74ab512c Mon Sep 17 00:00:00 2001 From: Efsane Soyer Date: Wed, 27 Mar 2024 17:15:26 -0700 Subject: [PATCH] made MIN_SLEEP_DURATION a platform property based on clk res --- core/threaded/reactor_threaded.c | 2 ++ include/core/reactor_common.h | 2 +- low_level_platform/api/platform/lf_unix_clock_support.h | 2 ++ low_level_platform/impl/src/lf_unix_clock_support.c | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/threaded/reactor_threaded.c b/core/threaded/reactor_threaded.c index e364675d6..62eaef6c2 100644 --- a/core/threaded/reactor_threaded.c +++ b/core/threaded/reactor_threaded.c @@ -28,6 +28,8 @@ #include "reactor_common.h" #include "watchdog.h" +#include "platform/lf_unix_clock_support.h" + #ifdef FEDERATED #include "federate.h" #endif diff --git a/include/core/reactor_common.h b/include/core/reactor_common.h index fc1451a96..3e0ec1a38 100644 --- a/include/core/reactor_common.h +++ b/include/core/reactor_common.h @@ -42,7 +42,7 @@ * to prevent unnecessary delays caused by simply setting up and * performing the wait. */ -#define MIN_SLEEP_DURATION USEC(10) +// #define MIN_SLEEP_DURATION USEC(10) ////////////////////// Global Variables ////////////////////// diff --git a/low_level_platform/api/platform/lf_unix_clock_support.h b/low_level_platform/api/platform/lf_unix_clock_support.h index 0a2c80163..ca6c4e033 100644 --- a/low_level_platform/api/platform/lf_unix_clock_support.h +++ b/low_level_platform/api/platform/lf_unix_clock_support.h @@ -1,6 +1,8 @@ #include #include +extern instant_t MIN_SLEEP_DURATION; + /** * @brief Convert a _lf_time_spec_t ('tp') to an instant_t representation in * nanoseconds. diff --git a/low_level_platform/impl/src/lf_unix_clock_support.c b/low_level_platform/impl/src/lf_unix_clock_support.c index b9c9fae56..30881408e 100644 --- a/low_level_platform/impl/src/lf_unix_clock_support.c +++ b/low_level_platform/impl/src/lf_unix_clock_support.c @@ -6,6 +6,8 @@ #include "logging.h" #include "platform/lf_unix_clock_support.h" +instant_t MIN_SLEEP_DURATION; + instant_t convert_timespec_to_ns(struct timespec tp) { return ((instant_t)tp.tv_sec) * BILLION + tp.tv_nsec; } struct timespec convert_ns_to_timespec(instant_t t) { @@ -23,6 +25,7 @@ void _lf_initialize_clock() { } lf_print("---- System clock resolution: %ld nsec", res.tv_nsec); + MIN_SLEEP_DURATION = NSEC(res.tv_nsec); } /**