mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
sched/wdog: Move the g_wdtimernested to sched_timerexpiration.
This commit moved the g_wdtimernested to sched_timerexpiration, since wdog and hrtimer can share it. Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
parent
e5db83d7db
commit
7d01d8aab5
2 changed files with 21 additions and 29 deletions
|
|
@ -100,6 +100,10 @@ static clock_t g_timer_tick;
|
|||
|
||||
static atomic_t g_timer_interval;
|
||||
|
||||
#ifdef CONFIG_SCHED_TICKLESS
|
||||
static unsigned int g_timernested;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -470,12 +474,19 @@ clock_t nxsched_timer_update(clock_t ticks, bool noswitches)
|
|||
void nxsched_timer_expiration(void)
|
||||
{
|
||||
clock_t ticks;
|
||||
irqstate_t flags = enter_critical_section();
|
||||
|
||||
/* Get the interval associated with last expiration */
|
||||
|
||||
g_timernested++;
|
||||
|
||||
up_timer_gettick(&ticks);
|
||||
|
||||
nxsched_timer_update(ticks, false);
|
||||
|
||||
g_timernested--;
|
||||
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
@ -519,17 +530,20 @@ void nxsched_reassess_timer(void)
|
|||
{
|
||||
clock_t ticks;
|
||||
|
||||
/* Cancel the timer and get the current time */
|
||||
if (!g_timernested)
|
||||
{
|
||||
/* Cancel the timer and get the current time */
|
||||
|
||||
#ifdef CONFIG_SCHED_TICKLESS_ALARM
|
||||
up_alarm_tick_cancel(&ticks);
|
||||
up_alarm_tick_cancel(&ticks);
|
||||
#else
|
||||
clock_t elapsed;
|
||||
up_timer_gettick(&ticks);
|
||||
up_timer_tick_cancel(&elapsed);
|
||||
clock_t elapsed;
|
||||
up_timer_gettick(&ticks);
|
||||
up_timer_tick_cancel(&elapsed);
|
||||
#endif
|
||||
|
||||
nxsched_timer_update(ticks, true);
|
||||
nxsched_timer_update(ticks, true);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
|
|
@ -85,14 +85,6 @@
|
|||
#define wdparm_to_ptr(type, arg) ((type)(uintptr_t)arg)
|
||||
#define ptr_to_wdparm(ptr) wdparm_to_ptr(wdparm_t, ptr)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SCHED_TICKLESS
|
||||
static unsigned int g_wdtimernested;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -121,14 +113,6 @@ static inline_function void wd_expiration(clock_t ticks)
|
|||
|
||||
flags = spin_lock_irqsave(&g_wdspinlock);
|
||||
|
||||
#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
|
||||
*/
|
||||
|
|
@ -173,12 +157,6 @@ static inline_function void wd_expiration(clock_t ticks)
|
|||
flags = spin_lock_irqsave(&g_wdspinlock);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SCHED_TICKLESS
|
||||
/* Decrement the nested watchdog timer count */
|
||||
|
||||
g_wdtimernested--;
|
||||
#endif
|
||||
|
||||
spin_unlock_irqrestore(&g_wdspinlock, flags);
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +291,7 @@ int wd_start_abstick(FAR struct wdog_s *wdog, clock_t ticks,
|
|||
|
||||
reassess |= wd_insert(wdog, ticks, wdentry, arg);
|
||||
|
||||
if (!g_wdtimernested && reassess)
|
||||
if (reassess)
|
||||
{
|
||||
/* Resume the interval timer that will generate the next
|
||||
* interval event. If the timer at the head of the list changed,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue