From e51656432c469c8daf1a77bf5d2a569d063f21b4 Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Sat, 25 Mar 2023 15:33:18 +0100 Subject: [PATCH 1/3] Made watchdog function match thread function signature --- core/reactor_common.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/reactor_common.c b/core/reactor_common.c index 09657a11d..08fcc623c 100644 --- a/core/reactor_common.c +++ b/core/reactor_common.c @@ -1318,7 +1318,8 @@ bool _lf_check_deadline(self_base_t* self, bool invoke_deadline_handler) { #ifdef LF_THREADED -void* run_watchdog(watchdog_t* watchdog) { +void* run_watchdog(void* arg) { + watchdog_t* watchdog = (watchdog_t*)arg; watchdog->thread_active = true; self_base_t* base = watchdog->base; lf_mutex_lock(&(base->watchdog_mutex)); @@ -1326,13 +1327,14 @@ void* run_watchdog(watchdog_t* watchdog) { while (lf_time_physical() < watchdog->expiration) { interval_t T = watchdog->expiration - lf_time_physical(); lf_mutex_unlock(&(base->watchdog_mutex)); - lf_nanosleep(T); + lf_sleep(T); lf_mutex_lock(&(base->watchdog_mutex)); } watchdog_function_t watchdog_func = watchdog->watchdog_function; - (*watchdog_func)(watchdog); + (*watchdog_func)(base); lf_mutex_unlock(&(base->watchdog_mutex)); watchdog->thread_active = false; + return NULL; } void _lf_watchdog_start(watchdog_t* watchdog, interval_t additional_timeout) { From b62683e826f3449d5a608febe33d724b66204927 Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Sat, 25 Mar 2023 15:33:57 +0100 Subject: [PATCH 2/3] Comment formatting only --- include/core/lf_types.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/core/lf_types.h b/include/core/lf_types.h index fa2d884c2..439347fec 100644 --- a/include/core/lf_types.h +++ b/include/core/lf_types.h @@ -146,7 +146,7 @@ typedef void(*reaction_function_t)(void*); * these watchdog functions is a pointer to the self struct * for the reactor. */ -typedef void(*watchdog_function_t)(void*); +typedef void(*watchdog_function_t)(void*); /** Trigger struct representing an output, timer, action, or input. See below. */ typedef struct trigger_t trigger_t; @@ -223,12 +223,12 @@ typedef struct watchdog_t watchdog_t; #ifdef LF_THREADED /** Watchdog struct for handler. */ struct watchdog_t { - struct self_base_t* base; // The reactor that contains the watchdog. + struct self_base_t* base; // The reactor that contains the watchdog. instant_t expiration; // The expiration instant for the watchdog. (Initialized to NEVER) interval_t min_expiration; // The minimum expiration interval for the watchdog. - lf_thread_t thread_id; // The thread that the watchdog is meant to run on. - bool thread_active; // Boolean indicating whether or not thread is active. - watchdog_function_t watchdog_function; // The function/handler for the watchdog. + lf_thread_t thread_id; // The thread that the watchdog is meant to run on. + bool thread_active; // Boolean indicating whether or not thread is active. + watchdog_function_t watchdog_function; // The function/handler for the watchdog. }; #endif From 24c0dc700bfde4ddf8a592fef82a837528006340 Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Sat, 25 Mar 2023 15:34:26 +0100 Subject: [PATCH 3/3] Made watchdog function conform with thread function --- include/core/reactor_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/core/reactor_common.h b/include/core/reactor_common.h index 460dec0a6..691a3e79b 100644 --- a/include/core/reactor_common.h +++ b/include/core/reactor_common.h @@ -78,7 +78,7 @@ void _lf_advance_logical_time(instant_t next_time); trigger_handle_t _lf_schedule_int(lf_action_base_t* action, interval_t extra_delay, int value); bool _lf_check_deadline(self_base_t* self, bool invoke_deadline_handler); #ifdef LF_THREADED -void* run_watchdog(watchdog_t* watchdog); +void* run_watchdog(void* watchdog); void _lf_watchdog_start(watchdog_t* watchdog, interval_t additional_timeout); void _lf_watchdog_stop(watchdog_t* watchdog); #endif