anduril13
anduril13

Reputation: 11

What portion of the Interrupt code is not preemptible?

This is from a Linux Device Driver course I am doing online. It seemed wrong and I wanted to make sure .... "Kernel code running in process context is preemptible. Interrupt context however, runs to completion and is not preemptible."

I thought there could always be higher priority interrupts that could preempt and would have to serviced earlier than the current interrupt ? Or does this have to do with top and bottom halves ? ie the top half runs to completion ?

Upvotes: 1

Views: 245

Answers (1)

Li Chen
Li Chen

Reputation: 5280

Some architectures do support interrupt preemption, take ARM's GIC for example if a higher priority interrupt wants to preempt an active but lower priority, it will

  1. GIC's arbitration unit will record and compare their priority and if this priority has the highest priority among all pending interrupts.
  2. If yes, preempt and send this highest priority interrupt to the CPU.
  3. CPU ack this highest priority interrupt then stop lower priority ISR at hand and switch to the highest priority one.

But Linux doesn't really support this feature, because it will disable all IRQ on the top half of ISR, which means though higher priority interrupts come, the CPU cannot ack any of them, so it has no way to handle it until the top half has done. That's why the top half should always be short and can never sleep. If you have slow things to do, just put them in the bottom halves, like workqueue, tasklet or else.

Upvotes: 1

Related Questions