Merge pull request #14565 from bergzand/pr/sched/fix_retrigger

sched: Prevent retriggering the scheduler interrupt during idle sleep
This commit is contained in:
Martine Lenders 2020-07-28 22:11:25 +02:00 committed by GitHub
commit b1bf8ab981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -102,7 +102,6 @@ static void _unschedule(thread_t *active_thread)
int __attribute__((used)) sched_run(void) int __attribute__((used)) sched_run(void)
{ {
sched_context_switch_request = 0;
thread_t *active_thread = (thread_t *)sched_active_thread; thread_t *active_thread = (thread_t *)sched_active_thread;
if (!IS_USED(MODULE_CORE_IDLE_THREAD)) { if (!IS_USED(MODULE_CORE_IDLE_THREAD)) {
@ -118,6 +117,8 @@ int __attribute__((used)) sched_run(void)
} }
} }
sched_context_switch_request = 0;
int nextrq = bitarithm_lsb(runqueue_bitcache); int nextrq = bitarithm_lsb(runqueue_bitcache);
thread_t *next_thread = container_of(sched_runqueues[nextrq].next->next, thread_t *next_thread = container_of(sched_runqueues[nextrq].next->next,
thread_t, rq_entry); thread_t, rq_entry);

View File

@ -474,4 +474,5 @@ void sched_arch_idle(void)
#endif #endif
irq_restore(state); irq_restore(state);
NVIC_SetPriority(PendSV_IRQn, CPU_CORTEXM_PENDSV_IRQ_PRIO); NVIC_SetPriority(PendSV_IRQn, CPU_CORTEXM_PENDSV_IRQ_PRIO);
SCB->ICSR = SCB_ICSR_PENDSVCLR_Msk;
} }