Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Something about interrupts of the same source

It is said that

When an interrupt is sent by the PIC, the PIC will not send another interrupt from that same source until it gets acknowledged through an I/O port. This is because interrupt handlers usually manipulate critical data structures and would not withstand being interrupted by new invocations of themselves (i.e. they are not reentrant).

I don't understand. Is there something different between interrupts of the same source and different source?

like image 484
venus.w Avatar asked Jan 26 '26 20:01

venus.w


2 Answers

You can get interrupts from different sources: timer, hard disk, network, etc. Each one of those interrupts will be handled by a different interrupt handler.

Therefore, if an interrupt from source (S1) arrives while another interrupt from source (S2) is being processed, there is no problem. Both interrupts are being handled by different interrupt handlers.

On the other hand, if an interrupt from source (S) arrives while the handler for that source is processing another interrupt, the handler will not be able to process the second one since it is not designed in a reentrant way (i.e., it cannot be interrupted, process the new interrupt, and then go back to process the original interrupt).

You may have a look at Understanding the Linux Kernel for detailed information on the way interrupts work in the Linux kernel.

like image 162
betabandido Avatar answered Jan 28 '26 10:01

betabandido


Interrupts from the same source will have to operate on the same data structures as the currently active interrupt. Interrupts from different sources will be operating on different data structures. So you can't have two interrupts from the same source active at the same time unless they were smart enough to coordinate their activities, and the current design prevents them from being active so that the programmer doesn't have to worry about that complexity.

Taking a (contrived) example from the real world, imagine a table where people go to pick up tickets for something, where there are different clerks for different ranges of the alphabet based on last name. Two people whose last name ends in A can't both pick up tickets at the same time because otherwise the clerk responsible for them might get confused and make a mistake. However, someone whose last name ends in A can pick up tickets at the same time as someone whose last name ends in Z because their respective clerks are operating on different lists of names and piles of tickets, so one won't negatively affect the other.

In this example, the letter of the customer's last name is the source, and the customer is the interrupt. The clerk is the interrupt handler, and the list of names and pile of tickets are the kernel data structures.

like image 26
dsolimano Avatar answered Jan 28 '26 10:01

dsolimano