IT lexicon › Programming › Interrupt context

Interrupt context

Programming På svenska → Updated: 2026-11-05

The state a processor is in while running an interrupt handler — no task of its own, no right to wait, and the rest of the system on hold.

Code in task context belongs to a thread the scheduler can set aside. Code in interrupt context belongs to nobody; it borrows the CPU from whoever happened to be running. So it must never block: there is no task to put to sleep, and whatever would wake it up may well be the very code it interrupted. No mutexes, no malloc that might wait, no printf over a slow UART.

On Cortex-M it corresponds to Handler mode on the main stack (MSP). In Linux, in_interrupt() answers the question, and sleeping there earns you the famous "scheduling while atomic". The standard fix is to do as little as possible and hand the rest to a task via deferred handling.

← Back to the lexicon