Skip to content
Tech Interview Prep
Technical interview guide

Interrupts & Interrupt Service Routines

How hardware interrupts preempt normal execution, and the discipline required to write an ISR that doesn't corrupt shared state or blow the interrupt budget.

Read
55 min
Practice MCQs
25
Interview Q&A
25
Edition
v3
Editorial status
Reviewed

Scope: CMSIS-Core 6.2 interrupt APIs; current FreeRTOS Cortex-M port guidance; current GCC interrupt attributes and Arm ABI reviewed 2026-09-04.

Curated: · Written: · Reviewed:

25 questions

MCQ-2A Cortex-M4 firmware image is linked so that the vector table sits at flash address 0x0800_4000, and the startup file defines a weak `Default_Handler` that is an infinite loop. The image is flashed and reset; the core immediately spins in `Default_Handler` even though `main()` and the UART ISR are present in the image. The linker script places `.isr_vector` at 0x0800_4000 and the reset handler symbol resolves correctly. What is the most likely cause?
MCQ-1A Cortex-M4 application is linked for flash at 0x08008000 and is entered by a bootloader at 0x08000000. TIM2 is set up for update interrupts (DIER.UIE = 1, CR1.CEN = 1), NVIC_EnableIRQ(TIM2_IRQn) and NVIC_SetPriority(TIM2_IRQn, 5) have both run, and SysTick fires normally. In the debugger, NVIC->ISER[0] bit 28 and NVIC->ISPR[0] bit 28 both read 1, and the PC is spinning in a handler in the bootloader's address range; the application's TIM2_IRQHandler never runs. What is the cause?
MCQ-24A Cortex-M4 has begun the exception-entry sequence for a low-priority IRQ: it has stacked the pre-empted context but has not yet fetched the vector. A higher-priority IRQ asserts now. The lower-priority handler never runs before the higher-priority handler. Which hardware behaviour explains this?
MCQ-5A Cortex-M NVIC-based firmware has an edge-triggered GPIO interrupt on EXTI line 3. The handler for EXTI3 is currently executing and has not yet returned. While it runs, the pin toggles again, re-asserting the same EXTI3 request. The handler reads the NVIC pending register for IRQ 9 (EXTI3) and sees the pending bit set. What does that pending bit tell the handler about the second edge?
MCQ-3An ATmega328P board runs a motor-control loop built with avr-gcc 5.4. The timer0 overflow handler is an ordinary C function, `void tick(void)`, whose address was written into the vector table by hand. On the bench the loop runs; in the field the tick counter reaches 1 and then never changes, and the main loop's position variable, a `uint16_t` the compiler keeps in r24:r25, is corrupted by that first overflow. Disassembly shows the handler saving only r0, r1, r28 and r29 and ending in `ret`. Which change removes both faults?
MCQ-20An SoC's interrupt controller samples each external IRQ input with a synchronizer clocked at 16 MHz, so the pin's level is captured once every 62.5 ns. A peripheral drives its IRQ line high for 20 ns when a packet arrives and holds it low otherwise, and the driver has the line configured as rising-edge-triggered. Under heavy traffic the driver loses about two of every three packets: the peripheral's status register shows the packet pending, but the ISR never ran. The packet buffer overflows 200 µs after a packet arrives. Which change fixes the loss?
MCQ-4A GPIO expander drives a level-sensitive interrupt line into an SoC's interrupt controller. Its INT pin stays asserted until the expander's status register is read over I2C. The ISR reads the controller's pending register, writes 1 to clear it, and returns. On the running board the ISR re-enters about 180,000 times per second, each entry costs 4 µs, and the CPU spends roughly 72% of its time in the ISR. Which change stops the re-entry?
MCQ-19A shared IRQ line is in a storm: /proc/interrupts reports the line's rate climbing by roughly 400,000 per second, the ISR returns IRQ_HANDLED every time, and the box is at 100% CPU in softirq with userspace making no progress. A second device on the same line is working normally. Which action fits this situation?
MCQ-15A tachometer pulses its IRQ line once per shaft revolution. The ISR is a single statement, `tick = true;`. A 10 ms control loop runs `if (tick) { revs++; tick = false; }`, with interrupts masked across the test and the clear, and the build is -O2. Bench facts: an ISR entry counter reads 200 entries/s at 12000 rpm; a GPIO toggle shows the loop period is a steady 10 ms; the disassembly loads `tick` on every pass; the ISR writes nothing but `tick`. `revs` climbs at about 100/s. Why?
MCQ-14A 16-bit MSP430 at 8 MHz runs a timer ISR every 1 ms that does `g_ticks++` on a `volatile uint32_t g_ticks`. Main reads `g_ticks` to compute elapsed milliseconds. The compiler emits two 16-bit loads for the read and two 16-bit stores for the increment. Occasionally main reports an elapsed time that is 65,536 ms too large or too small. Which change removes that anomaly?
MCQ-16A single-producer ISR ring on a 32-bit MCU uses uint16_t head and tail, with a buffer of 8 slots and one slot always left empty, so at most 7 samples are queued. The ISR runs at 10 kHz, writes the next slot, then increments head. The consumer drains while the unsigned 16-bit difference head - tail is nonzero, then increments tail. After 6.554 s (65,540 ISR ticks), head has wrapped to 4 and tail is 65534. A new build replaces the consumer test with int diff = head - tail; if (diff <= 0) return EMPTY;. At that instant, how many samples are queued, and what should the consumer do?
MCQ-25A Cortex-M4 firmware's SysTick ISR calls the same logging routine the main loop uses; that routine formats into a static buffer and takes a mutex. Under load the device hangs with the ISR never returning. Which change removes the hazard?
MCQ-21An ISR runs when a receive DMA engine reports a completed frame written into ordinary write-back cacheable memory, and the DMA master claims on the interconnect as a non-coherent device (no ACE/ACP or CCI snooping of the CPU caches). Before the ISR sets the flag that the worker thread polls ahead of reading the frame, which step does it still owe?
MCQ-23A Cortex-M4 product reboots in the field about every 90 seconds. The hard fault handler fills a 256-byte record (fault status register, stacked PC and LR, build ID, reset cause) then calls NVIC_SystemReset(). Reading the record inside the handler just before the reset shows it fully populated. After the reboot, the code that reads the record gets 256 zero bytes. The record is a file-scope variable with no initializer. What is the first change that makes the record survive the reboot?
MCQ-9A sensor streams bytes into a Cortex-M MCU's UART at 115200 baud, 8N1. The receiver has a single-byte data register, no FIFO, no DMA and no flow control, and the driver's RX ISR reads that register and takes 3.0 us from interrupt entry to the read. A frame is transferred into the register at the end of its stop bit, so with back-to-back frames each transfer follows the previous one by exactly one frame time. A flash-update routine wraps its work in a global interrupt mask (PRIMASK set with __disable_irq()); at 200 us long, the driver is losing bytes. What is the longest global mask window that will never drop a byte, whatever the alignment between the mask and the incoming stream?
MCQ-6A Cortex-M4 device is built with __NVIC_PRIO_BITS = 3. A debugger reads the NVIC_IPR byte for IRQ_A as 0x40 and for IRQ_B as 0x80. Which IRQ preempts the other, and why?
MCQ-7An STM32F407 (Cortex-M4, four implemented priority bits) is configured so that bits [7:5] of each 8-bit priority field are preemption priority and bit [4] is subpriority. Interrupt A's field is 0x30 and interrupt B's is 0x20. B is asserted while A's handler is executing. What does the NVIC do?
MCQ-8A Cortex-M firmware runs two interrupt sources on the same NVIC priority level: a 1 kHz ADC end-of-conversion ISR that takes about 4 µs, and a UART RX ISR that takes about 30 µs. The UART ISR is executing when the ADC conversion completes. Both handlers are written in C and neither disables interrupts. What happens next?
MCQ-13A 1 kHz control loop runs from a timer ISR at priority 0 with an 8 µs execution budget. A UART RX ISR at priority 1 handles 64-byte frames at 115200 baud; its CRC-16 and frame parse run with interrupts masked for a measured 58 µs per frame. Control-loop jitter p99 rose from 3 µs to 61 µs. Which change restores the deadline?
MCQ-17A Cortex-M4 board runs a 168 MHz control loop. A timer ISR at priority 1 takes 3 µs of handler code. A UART ISR at priority 0 (higher urgency) fires every 500 µs and runs 40 µs. A 2 ms critical section in the main loop masks interrupts with PRIMASK. Bench measurements show the timer ISR's assertion-to-first-instruction latency spiking to 2.1 ms even though its own handler is only 3 µs. What is the dominant contributor to that 2.1 ms worst-case latency?
MCQ-10A Cortex-M4 at 168 MHz runs an ADC-complete ISR at priority 1 that must be serviced within 2 µs, and a control-loop ISR at priority 5. The control loop guards a shared ring buffer with a critical section that runs about 3 µs, bracketed by `__set_BASEPRI(5)` and `__set_BASEPRI(0)`. On this part the NVIC priority field occupies bits 7:4 of each IPR byte. Worst-case ADC-ISR latency has risen from 0.5 µs to 3.5 µs. Which change restores the ADC-ISR latency while still keeping the control-loop ISR out of the critical section?
MCQ-11A Cortex-M4 FreeRTOS port is built with configPRIO_BITS = 4 and configMAX_SYSCALL_INTERRUPT_PRIORITY = 5 (NVIC register value 0x50). The ADC ISR is configured with NVIC IP register value 0x30. What happens if that ISR calls xQueueSendFromISR()?
MCQ-12A FreeRTOS 10.x Cortex-M4 build uses configTICK_RATE_HZ = 1000 and configUSE_PREEMPTION = 1. A consumer task at priority 3 blocks in xQueueReceive on a 4-deep queue. A timer ISR at priority 5, which interrupts the idle task, fires every 2 ms and calls xQueueSendFromISR(q, &sample, &xHigherPriorityTaskWoken). xHigherPriorityTaskWoken was initialised to pdFALSE and is never read again, and the ISR never calls portYIELD_FROM_ISR. The queue never fills. How long after a send does the consumer task start running?
MCQ-22A Cortex-M RTOS runs SysTick at 1 kHz. The tick ISR calls a 600 µs sensor-fusion routine before returning to the scheduler. At runtime, a 115200-baud UART RX interrupt loses bytes during sensor bursts, and a 2 ms control task occasionally misses its deadline. Profiling confirms the tick ISR runs 600 µs every 1 ms. Which diagnosis and first change fit these measurements?
MCQ-18A 1 kHz timer ISR takes 6 µs on its normal path and 700 µs when it flushes a full error log, which happens about once every 200 ticks. The control task it feeds has a 400 µs deadline. The team calls the ISR 'fast enough' because its mean is 9.5 µs. Why is that reasoning invalid?