diff --git a/arch/arm/core/exc_exit.S b/arch/arm/core/exc_exit.S index c8e8250b629..64bf2ef4771 100644 --- a/arch/arm/core/exc_exit.S +++ b/arch/arm/core/exc_exit.S @@ -103,6 +103,28 @@ SECTION_SUBSEC_FUNC(TEXT, _HandlerModeExit, _ExcExit) bgt _EXIT_EXC push {lr} + + /* + * _is_next_thread_current() calls _get_next_ready_thread(), which is + * supposed to be called only with interrupts locked: interrupts are _not_ + * locked at this point. However, that is not a problem in this case: + * + * - Threads can only be added to the ready queue in an ISR, not removed. + * Thus, priorities with runnable thread can only be added as well. + * + * - The PendSV handler is the context that will decide which thread to + * run, not the current context. + * + * - The current decision to pend PendSV or not is started with the ready + * queue state that the currently exiting ISR updated: if that state + * changes, it can only be to add a thread as runnable, not remove one. + * + * - The only discrepancy that can happen is if another ISR preempts the + * current one and makes another thread than the current the next thread + * to run, if the current ISR did not do already that. In that case, even + * if the decision is interrupted, the current code running in the higher + * priority ISR _will_ take the correct decision to pend PendSV. + */ blx _is_next_thread_current #if defined(CONFIG_CPU_CORTEX_M0_M0PLUS) pop {r1}