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 <wangchengdong@lixiang.com>
This commit is contained in:
wangchengdong 2025-11-05 18:30:19 +08:00 • committed by Xiang Xiao
parent aa3cf8cb3a
commit 1217fcf907

View file

@ -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 */