From 66871ced4d29b119159b3ab6c02892feac520760 Mon Sep 17 00:00:00 2001 From: ouyangxiangzhen Date: Mon, 15 Jul 2024 11:08:55 +0800 Subject: [PATCH] sched/wdog: move g_wdtimernested to wd_start.c This patch moved the g_wdtimernested to wd_start.c Signed-off-by: ouyangxiangzhen Signed-off-by: ligd --- sched/sched/sched_timerexpiration.c | 2 -- sched/wdog/wd_initialize.c | 4 ---- sched/wdog/wd_start.c | 22 ++++++++++++++++++++++ sched/wdog/wdog.h | 4 ---- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/sched/sched/sched_timerexpiration.c b/sched/sched/sched_timerexpiration.c index 08fe7f0765c..6c80fb23456 100644 --- a/sched/sched/sched_timerexpiration.c +++ b/sched/sched/sched_timerexpiration.c @@ -528,9 +528,7 @@ void nxsched_alarm_tick_expiration(clock_t ticks) /* Process the timer ticks and set up the next interval (or not) */ - g_wdtimernested++; nexttime = nxsched_timer_process(ticks, elapsed, false); - g_wdtimernested--; nxsched_timer_start(nexttime); #ifdef CONFIG_SMP diff --git a/sched/wdog/wd_initialize.c b/sched/wdog/wd_initialize.c index 00c70a5be5c..98d43595835 100644 --- a/sched/wdog/wd_initialize.c +++ b/sched/wdog/wd_initialize.c @@ -39,10 +39,6 @@ struct list_node g_wdactivelist = LIST_INITIAL_VALUE(g_wdactivelist); -#ifdef CONFIG_SCHED_TICKLESS -unsigned int g_wdtimernested; -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/sched/wdog/wd_start.c b/sched/wdog/wd_start.c index 0fdb48213ba..4fa0996dc35 100644 --- a/sched/wdog/wd_start.c +++ b/sched/wdog/wd_start.c @@ -69,6 +69,14 @@ # define CALL_FUNC(func, arg) func(arg) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef CONFIG_SCHED_TICKLESS +static unsigned int g_wdtimernested; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -93,6 +101,14 @@ static inline_function void wd_expiration(clock_t ticks) FAR struct wdog_s *wdog; wdentry_t func; +#ifdef CONFIG_SCHED_TICKLESS + /* Increment the nested watchdog timer count to handle cases where wd_start + * is called in the watchdog callback functions. + */ + + g_wdtimernested++; +#endif + /* Process the watchdog at the head of the list as well as any * other watchdogs that became ready to run at this time */ @@ -122,6 +138,12 @@ static inline_function void wd_expiration(clock_t ticks) up_setpicbase(wdog->picbase); CALL_FUNC(func, wdog->arg); } + +#ifdef CONFIG_SCHED_TICKLESS + /* Decrement the nested watchdog timer count */ + + g_wdtimernested--; +#endif } /**************************************************************************** diff --git a/sched/wdog/wdog.h b/sched/wdog/wdog.h index a19830f3487..636257cdbcd 100644 --- a/sched/wdog/wdog.h +++ b/sched/wdog/wdog.h @@ -63,10 +63,6 @@ extern "C" extern struct list_node g_wdactivelist; -#ifdef CONFIG_SCHED_TICKLESS -extern unsigned int g_wdtimernested; -#endif - /**************************************************************************** * Public Function Prototypes ****************************************************************************/