Interrupts & ISR Design Questions
Handling asynchronous hardware events: the interrupt mechanism, interrupt vectors and priorities, writing interrupt service routines, and the interplay between interrupt context and normal execution. Covers keeping ISRs short, deferring work to bottom halves, protecting shared state from interrupt preemption, and latency considerations.
Implement a single-producer single-consumer ring buffer in C to be used for deferred work handoff from an ISR to a main task. Requirements: the buffer stores void* pointers, capacity is a compile-time power of two, no dynamic allocation, enqueue() is called from ISR context and must be non-blocking and ISR-safe, dequeue() called from task context. Use C11 atomics (or explain why simple volatile with memory barrier is sufficient). Provide enqueue and dequeue implementations and explain ordering guarantees.
Design a wake-from-sleep strategy for a battery-powered device that must sleep most of the time and wake on external GPIO input or RTC alarm. Discuss which interrupts can wake the device from deep sleep, how to debounce wakes, minimize false wakes due to noise, and how to balance wake latency with power consumption.
Architect interrupt routing in a multi-core embedded SoC where peripheral interrupts need to be load-balanced across cores while maintaining low latency for real-time tasks. Explain routing strategies (affinity, dynamic steering), cache-coherency implications, per-core ISR stacks, and how DMA and interrupt affinity should interact.
In C for ARM Cortex-M (GCC), write a minimal GPIO interrupt service routine (ISR) for a falling-edge input that: 1) clears the hardware interrupt flag, 2) does not block or call heap allocation, and 3) notifies the main application via a lock-free flag or OS task-notification (assume FreeRTOS if you prefer). Provide the handler signature and any attributes or volatile variables needed.
Implement an ISR-safe logging mechanism that replaces printf calls in interrupts. Requirements: minimal overhead in ISR, no heap use, store textual or binary events to a fixed-size RAM circular buffer, provide a non-blocking API for ISR to append events, and a consumer in main context to flush to UART/flash. Provide C code for append() and consumer() functions and discuss crash/power-loss considerations.
Unlock Full Question Bank
Get access to all 33 Interrupts & ISR Design interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.