From 1217fcf9071627fc2a0691ffd990c69b958f808f Mon Sep 17 00:00:00 2001 From: wangchengdong Date: Wed, 5 Nov 2025 18:30:19 +0800 Subject: [PATCH] sched/wdog: Improve wdog Precision Currently, wd_timer() obtains the current systick from the input parameter, and the wdog processes the list without updating the systick value. This is not incorrect, as the systick should continue to increase while the watchdog is processing callbacks. This patch addresses the issue by retrieving the updated systick value after each watchdog node loop. Signed-off-by: Chengdong Wang --- sched/wdog/wd_start.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sched/wdog/wd_start.c b/sched/wdog/wd_start.c index 3850ccaf89e..135c8326603 100644 --- a/sched/wdog/wd_start.c +++ b/sched/wdog/wd_start.c @@ -137,11 +137,21 @@ static inline_function void wd_expiration(clock_t ticks) { wdog = list_first_entry(&g_wdactivelist, struct wdog_s, node); - /* Check if expected time is expired */ + /* Check if watchdog has expired; + * re-evaluate after updating current ticks if needed + */ - if (!clock_compare(wdog->expired, ticks)) + bool expired = clock_compare(wdog->expired, ticks); + + if (!expired) { - break; + ticks = clock_systime_ticks(); + expired = clock_compare(wdog->expired, ticks); + + if (!expired) + { + break; + } } /* Remove the watchdog from the head of the list */