IT lexicon › Hardware › Thread mode and handler mode

Thread mode and handler mode

Hardware På svenska → Updated: 2026-11-04

The two execution modes of a Cortex-M core: one for ordinary code, and one for code that runs because something interrupted it.

Out of reset the processor runs in thread mode, home to main() and every RTOS task. Taking an interrupt or exception switches it to handler mode, which is always privileged and always uses the main stack, MSP. Thread mode, by contrast, can run unprivileged and on the process stack, PSP, as selected by the CONTROL register.

The split is why an RTOS on Cortex-M can be so compact. Each task gets its own PSP stack while all interrupts share the MSP, so no task stack has to be sized for worst-case interrupt nesting. Unprivileged code can't touch the NVIC or system registers and must ask the kernel through SVC. Which mode and stack a return goes back to is encoded in EXC_RETURN.

← Back to the lexicon