Skip to content

Commit ebf7f5f

Browse files
Fix-Pointxiaoxiang781216
authored andcommitted
sched/sched: Fix recursive watchdog handling
This commit fixed recursive watchdog handling caused by calling wd_start within watchdog timeout callback function. Signed-off-by: ouyangxiangzhen <[email protected]> Signed-off-by: ligd <[email protected]>
1 parent 3b111c8 commit ebf7f5f

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

sched/sched/sched_timerexpiration.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,9 @@ void nxsched_alarm_tick_expiration(clock_t ticks)
528528

529529
/* Process the timer ticks and set up the next interval (or not) */
530530

531+
g_wdtimernested++;
531532
nexttime = nxsched_timer_process(ticks, elapsed, false);
533+
g_wdtimernested--;
532534

533535
nxsched_timer_start(nexttime);
534536
#ifdef CONFIG_SMP

sched/wdog/wd_initialize.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939

4040
struct list_node g_wdactivelist = LIST_INITIAL_VALUE(g_wdactivelist);
4141

42+
#ifdef CONFIG_SCHED_TICKLESS
43+
unsigned int g_wdtimernested;
44+
#endif
45+
4246
/****************************************************************************
4347
* Public Functions
4448
****************************************************************************/

sched/wdog/wd_start.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ int wd_start_absolute(FAR struct wdog_s *wdog, clock_t ticks,
252252
wd_insert(wdog, ticks, wdentry, arg);
253253

254254
reassess |= list_is_head(&g_wdactivelist, &wdog->node);
255-
if (reassess)
255+
if (!g_wdtimernested && reassess)
256256
{
257257
/* Resume the interval timer that will generate the next
258258
* interval event. If the timer at the head of the list changed,

sched/wdog/wdog.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ extern "C"
6363

6464
extern struct list_node g_wdactivelist;
6565

66+
#ifdef CONFIG_SCHED_TICKLESS
67+
extern unsigned int g_wdtimernested;
68+
#endif
69+
6670
/****************************************************************************
6771
* Public Function Prototypes
6872
****************************************************************************/

0 commit comments

Comments
 (0)