Skip to content

Commit

Permalink
made MIN_SLEEP_DURATION a platform property based on clk res
Browse files Browse the repository at this point in the history
  • Loading branch information
soyerefsane committed Mar 28, 2024
1 parent 75fcdba commit 22d49a1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/threaded/reactor_threaded.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "reactor_common.h"
#include "watchdog.h"

#include "platform/lf_unix_clock_support.h"

#ifdef FEDERATED
#include "federate.h"
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/core/reactor_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 //////////////////////

Expand Down
2 changes: 2 additions & 0 deletions low_level_platform/api/platform/lf_unix_clock_support.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <time.h>
#include <errno.h>

extern instant_t MIN_SLEEP_DURATION;

/**
* @brief Convert a _lf_time_spec_t ('tp') to an instant_t representation in
* nanoseconds.
Expand Down
3 changes: 3 additions & 0 deletions low_level_platform/impl/src/lf_unix_clock_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit 22d49a1

Please sign in to comment.