Commit 42036cdb authored by Wilfried Chauveau's avatar Wilfried Chauveau Committed by Carles Cufi
Browse files

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: default avatarWilfried Chauveau <wilfried.chauveau@arm.com>
parent 773739a5
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -55,9 +55,14 @@ 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 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 */

#ifdef CONFIG_STACK_SENTINEL