Browse Source

arch: arm: cortex_m: Only trigger context switch if thread is preemptible

This is a fix for #61761 where a cooperative task is switched from at the
end of an exception. A cooperative thread should only be switched from if
the thread exists the ready state.

Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
pull/71524/head
Wilfried Chauveau 1 year ago committed by Carles Cufí
parent
commit
42036cdbca
  1. 9
      arch/arm/core/cortex_m/exc_exit.c

9
arch/arm/core/cortex_m/exc_exit.c

@ -55,8 +55,13 @@ FUNC_ALIAS(z_arm_exc_exit, z_arm_int_exit, void); @@ -55,8 +55,13 @@ FUNC_ALIAS(z_arm_exc_exit, z_arm_int_exit, void);
Z_GENERIC_SECTION(.text._HandlerModeExit) void z_arm_exc_exit(void)
{
#ifdef CONFIG_PREEMPT_ENABLED
if (_kernel.ready_q.cache != _kernel.cpus->current) {
SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk;
/* If thread is preemptible */
if (_kernel.cpus->current->base.prio >= 0) {
/* and cached thread is not current thread */
if (_kernel.ready_q.cache != _kernel.cpus->current) {
/* trigger a context switch */
SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk;
}
}
#endif /* CONFIG_PREEMPT_ENABLED */

Loading…
Cancel
Save