sched/wdog: move SMP enter_critical_section to sched_timerexpiration.c
Change-Id: Id654e6d2151e3b807ed2df4ab8169b90ab07b015 Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
9116ed9247
commit
35379403f8
@ -142,6 +142,42 @@ static inline void nxsched_process_scheduler(void)
|
|||||||
# define nxsched_process_scheduler()
|
# define nxsched_process_scheduler()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxsched_process_wdtimer
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Wdog timer process, should with critical_section when SMP mode.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
static inline void nxsched_process_wdtimer(void)
|
||||||
|
{
|
||||||
|
irqstate_t flags;
|
||||||
|
|
||||||
|
/* We are in an interrupt handler and, as a consequence, interrupts are
|
||||||
|
* disabled. But in the SMP case, interrupts MAY be disabled only on
|
||||||
|
* the local CPU since most architectures do not permit disabling
|
||||||
|
* interrupts on other CPUS.
|
||||||
|
*
|
||||||
|
* Hence, we must follow rules for critical sections even here in the
|
||||||
|
* SMP case.
|
||||||
|
*/
|
||||||
|
|
||||||
|
flags = enter_critical_section();
|
||||||
|
wd_timer();
|
||||||
|
leave_critical_section(flags);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define nxsched_process_wdtimer() wd_timer()
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -210,7 +246,7 @@ void nxsched_process_timer(void)
|
|||||||
|
|
||||||
/* Process watchdogs */
|
/* Process watchdogs */
|
||||||
|
|
||||||
wd_timer();
|
nxsched_process_wdtimer();
|
||||||
|
|
||||||
#ifdef CONFIG_SYSTEMTICK_HOOK
|
#ifdef CONFIG_SYSTEMTICK_HOOK
|
||||||
/* Call out to a user-provided function in order to perform board-specific,
|
/* Call out to a user-provided function in order to perform board-specific,
|
||||||
|
@ -313,6 +313,47 @@ static uint32_t nxsched_process_scheduler(uint32_t ticks, bool noswitches)
|
|||||||
# define nxsched_process_scheduler(t,n) (0)
|
# define nxsched_process_scheduler(t,n) (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxsched_process_wdtimer
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Wdog timer process, should with critical_section when SMP mode.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* ticks - The number of ticks that have elapsed on the interval timer.
|
||||||
|
* noswitches - True: Can't do context switches now.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The number of ticks for the next delay is provided (zero if no delay).
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
static inline unsigned int nxsched_process_wdtimer(uint32_t ticks,
|
||||||
|
bool noswitches)
|
||||||
|
{
|
||||||
|
unsigned int ret;
|
||||||
|
irqstate_t flags;
|
||||||
|
|
||||||
|
/* We are in an interrupt handler and, as a consequence, interrupts are
|
||||||
|
* disabled. But in the SMP case, interrupts MAY be disabled only on
|
||||||
|
* the local CPU since most architectures do not permit disabling
|
||||||
|
* interrupts on other CPUS.
|
||||||
|
*
|
||||||
|
* Hence, we must follow rules for critical sections even here in the
|
||||||
|
* SMP case.
|
||||||
|
*/
|
||||||
|
|
||||||
|
flags = enter_critical_section();
|
||||||
|
ret = wd_timer(ticks, noswitches);
|
||||||
|
leave_critical_section(flags);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define nxsched_process_wdtimer(t,n) wd_timer(t,n)
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxsched_timer_process
|
* Name: nxsched_timer_process
|
||||||
*
|
*
|
||||||
@ -344,7 +385,7 @@ static unsigned int nxsched_timer_process(unsigned int ticks,
|
|||||||
|
|
||||||
/* Process watchdogs */
|
/* Process watchdogs */
|
||||||
|
|
||||||
tmp = wd_timer(ticks, noswitches);
|
tmp = nxsched_process_wdtimer(ticks, noswitches);
|
||||||
if (tmp > 0)
|
if (tmp > 0)
|
||||||
{
|
{
|
||||||
cmptime = tmp;
|
cmptime = tmp;
|
||||||
|
@ -367,25 +367,9 @@ int wd_start(FAR struct wdog_s *wdog, int32_t delay,
|
|||||||
unsigned int wd_timer(int ticks, bool noswitches)
|
unsigned int wd_timer(int ticks, bool noswitches)
|
||||||
{
|
{
|
||||||
FAR struct wdog_s *wdog;
|
FAR struct wdog_s *wdog;
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
irqstate_t flags;
|
|
||||||
#endif
|
|
||||||
unsigned int ret;
|
unsigned int ret;
|
||||||
int decr;
|
int decr;
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
/* We are in an interrupt handler as, as a consequence, interrupts are
|
|
||||||
* disabled. But in the SMP case, interrupts MAY be disabled only on
|
|
||||||
* the local CPU since most architectures do not permit disabling
|
|
||||||
* interrupts on other CPUS.
|
|
||||||
*
|
|
||||||
* Hence, we must follow rules for critical sections even here in the
|
|
||||||
* SMP case.
|
|
||||||
*/
|
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Check if there are any active watchdogs to process */
|
/* Check if there are any active watchdogs to process */
|
||||||
|
|
||||||
wdog = (FAR struct wdog_s *)g_wdactivelist.head;
|
wdog = (FAR struct wdog_s *)g_wdactivelist.head;
|
||||||
@ -428,10 +412,6 @@ unsigned int wd_timer(int ticks, bool noswitches)
|
|||||||
ret = g_wdactivelist.head ?
|
ret = g_wdactivelist.head ?
|
||||||
MAX(((FAR struct wdog_s *)g_wdactivelist.head)->lag, 1) : 0;
|
MAX(((FAR struct wdog_s *)g_wdactivelist.head)->lag, 1) : 0;
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
leave_critical_section(flags);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Return the delay for the next watchdog to expire */
|
/* Return the delay for the next watchdog to expire */
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -440,21 +420,6 @@ unsigned int wd_timer(int ticks, bool noswitches)
|
|||||||
#else
|
#else
|
||||||
void wd_timer(void)
|
void wd_timer(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
irqstate_t flags;
|
|
||||||
|
|
||||||
/* We are in an interrupt handler as, as a consequence, interrupts are
|
|
||||||
* disabled. But in the SMP case, interrupts MAY be disabled only on
|
|
||||||
* the local CPU since most architectures do not permit disabling
|
|
||||||
* interrupts on other CPUS.
|
|
||||||
*
|
|
||||||
* Hence, we must follow rules for critical sections even here in the
|
|
||||||
* SMP case.
|
|
||||||
*/
|
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Check if there are any active watchdogs to process */
|
/* Check if there are any active watchdogs to process */
|
||||||
|
|
||||||
if (g_wdactivelist.head)
|
if (g_wdactivelist.head)
|
||||||
@ -467,9 +432,5 @@ void wd_timer(void)
|
|||||||
|
|
||||||
wd_expiration();
|
wd_expiration();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
leave_critical_section(flags);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SCHED_TICKLESS */
|
#endif /* CONFIG_SCHED_TICKLESS */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user