1

From this accepted answer:

There is no difference in Interrupt handler and ISR.

There is another answer that explains but it's not so clear to me.

From Understanding the Linux Kernel, 3rd Edition:

Remember that the interrupt service routines of an interrupt handler are serialized, and often there should be no occurrence of an interrupt until the corresponding interrupt handler has terminated. Conversely, the deferrable tasks can execute with all interrupts enabled.

This is causing a confusion for me. What does "interrupt service routines of an interrupt handler" mean?

StackExchange123
  • 1,871
  • 9
  • 24

2 Answers2

2

Linux handles interrupts by pointing each IDT descriptor to a bit of common code that sequentially executes a list of interrupt service routines until one of them handles the interrupt. This is needed because of things like IRQ sharing, where multiple devices are on a single IRQ and you don't know which one.

When you register a driver function to be called when some interrupt occurs using request_irq(irq, &driver_function, ...), you're not actually changing the entry in the IDT. But rather the address of your function is put into a new irqaction descriptor, which is added to a chain of other irqaction descriptors, which are then serially executed by the kernel when the interrupt occurs, until one of them returns that it was able to handle the interrupt.

So the term "Interrupt Service Routine" refers to these functions that are executed one by one when an interrupt happens. When you register a driver function to run when an interrupt occurs, you're actually registering it as an Interrupt Service Routine for a vector. There can be many ISRs for any vector.

The term "Interrupt handler" refers to the block of common code in the Linux kernel that is actually pointed to by the IDT that actually executes all of your ISRs one by one. It can also refer to the entire set of code that is executed when an interrupt occurs, and ISRs are elements of that set. From the instruction pointed to by the IDT descriptor, to the final iret instruction, including any ISRs that were or can be executed. But the key takeaway is that there is only one interrupt handler per vector.

The confusion is because "interrupt handler" is a very general term, while "Interrupt Service Routine" refers to something more specific in the Linux context. Outside of this context, they are frequently interchanged and considered to mean the same thing.

I've read the book you're citing, and this is how the book is using these terms.

Matviy Kotoniy
  • 362
  • 1
  • 13
1

Not knowing the context, I can understand the text in two different ways:

first

In most modern operating systems the actual interrupt handler is a function in the operating system which does some operations, calls a function in a device driver and then performs some more operations.

Both the words "interrupt service routine" and "interrupt handler" might be used for the function in the operating system or for the function in the device driver.

The book may name the operating system's function "interrupt handler" and the function in the driver "interrupt service routine". In this case the book describes how different device drivers handling the same interrupt work.

second

When an interrupt occurs, the "interrupt service routine" is started. The book names the function itself "interrupt handler" and each time the function is started, the book speaks about one "interrupt service routine".

In this case the book describes what exactly happens if an interrupt occurs multiple times and the "interrupt service routine" has not finished before the next interrupt happens.

Martin Rosenau
  • 17,897
  • 3
  • 19
  • 38