From fe30f0fa82c69e5c1460b88da3c0703c0eae8c42 Mon Sep 17 00:00:00 2001 From: yangguangcai Date: Fri, 25 Aug 2023 20:56:24 +0800 Subject: [PATCH] sched/wdog:change g_wdtickbase update situation. In the 'wd_timer',the callback function executed by 'wd_expiration' could call wd_start,and g_wdtickbase might be updated.Subsequently, g_wdtickbase is incremented by the value of ticks, causing g_wdtickbase to be greater than the actual passage of time. Signed-off-by: yangguangcai --- sched/wdog/wd_start.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sched/wdog/wd_start.c b/sched/wdog/wd_start.c index a3655d5a229b2..cd031ca7d49fd 100644 --- a/sched/wdog/wd_start.c +++ b/sched/wdog/wd_start.c @@ -373,6 +373,10 @@ unsigned int wd_timer(int ticks, bool noswitches) unsigned int ret; int decr; + /* Update clock tickbase */ + + g_wdtickbase += ticks; + /* Check if there are any active watchdogs to process */ wdog = (FAR struct wdog_s *)g_wdactivelist.head; @@ -386,7 +390,6 @@ unsigned int wd_timer(int ticks, bool noswitches) wdog->lag -= decr; ticks -= decr; - g_wdtickbase += decr; wdog = wdog->next; } @@ -398,10 +401,6 @@ unsigned int wd_timer(int ticks, bool noswitches) wd_expiration(); } - /* Update clock tickbase */ - - g_wdtickbase += ticks; - /* Return the delay for the next watchdog to expire */ ret = g_wdactivelist.head ?