Interrupts

4 Posts

Which Parts of an Interrupt Path Come From CPU Architecture, Interrupt Controllers, and the OS?

8 minute

When debugging interrupts, it is easy to call everything “the interrupt.”

A peripheral status bit was not cleared: interrupt problem. The interrupt controller was not enabled: interrupt problem. The CPU never entered exception entry: interrupt problem. The ISR ran but the task did not wake: also interrupt problem. Everyone is debugging “interrupts,” but not the same layer.

The safer first model is this: an interrupt is a cross-layer path. A peripheral creates an event, the SoC routes that event to an interrupt controller, the controller selects, masks, prioritizes, and delivers it, the CPU receives it through exception entry, and the OS maps it to an ISR, bottom half, thread, or task wakeup.

Read More

Why the RTOS Path From ISR to Task Must Be Designed

6 minute

In RTOS devices, many peripheral issues are not about whether an interrupt entered. They are about whether the task handled it correctly and soon enough after the ISR.

Common symptoms include:

  • ISR logs appear, but the business task receives no data
  • queues fill up when interrupt rate increases
  • ISR does too much work and system response gets worse
  • a high-priority task is woken but runs late
  • normal APIs are called from ISR and cause assertions or deadlocks
  • one notification is sent while the hardware FIFO already contains many events

Do not look only at the ISR function. The full path is:

Read More

How Interrupts, Wait Queues, and poll Connect in Linux Drivers

7 minute

An application waits on a device fd with poll() or epoll_wait(). The hardware has already raised an interrupt, but the application never wakes. Or the application wakes repeatedly, but read() returns no data.

This kind of bug usually does not live in one function. It comes from interrupts, buffers, wait queues, and poll semantics not agreeing with each other.

A hardware interrupt does not deliver data directly to an application. It only tells the CPU that a device event happened. The driver must turn that event into kernel-visible state and wake the processes waiting for it.

Read More

Why an Interrupt Is Not a Normal Function Call

10 minute

Device software often creates a misleading mental model: code runs in source order, and the next thing only happens after the current function returns. That model is useful inside a single function, but it breaks down as soon as timers, UART input, network packets, GPIO events, and DMA completion enter the system.

A peripheral does not wait until the main loop reaches the right line. A UART byte arrives when it arrives. A network packet arrives when it arrives. A timer expires when it expires. If the CPU had to discover every event by polling, response would either be slow or the system would waste a large amount of time checking status bits.

Read More