Question

Sorry, I wasn't sure if this was a suitable place to ask this, but I hope it is acceptable, apologies if it isn't ! :)

I am currently doing a module in Operating Systems theory and I have a few concepts that I am unable to grasp - would this be the right place to ask questions ?

My main question is about interrupts. When the CPU detects that there has been an interrupt, I understand that it must find out where this interrupt originated. My understanding is as follows, could anyone tell me if this is correct, and explain a few gaps in my knowledge ?

For the CPU to detect where the interrupt originated, it could query all objects to identify the source, but these I/O based questions would take a long time. Instead, it uses the interrupt cycle, and expects an interrupt identifier on the data bus. If it is an 8 bit data bus, there is 256 interrupt levels (i.e 2^8). (Why is this?)

So an Interrupt Service Routine (ISR) is written for every possible interrupt level and stored in a table at a fixed location (interrupt vector) which is standardized by the processor. In my notes is says "Location must be known before getting the address" (What does this mean?)

The interrupt level identifier received as part of the interrupt cycle is used as an index into the interrupt vector (Can someone break this down a little please?). My understanding is that a value, the interrupt level identifier is passed to the CPU and used to point at the interrupt vector.

Also, what does it mean when an interrupt is said to be "serviced"?

Thank you very much, and sorry for the long paragraphs, I am just a little confused by many aspects of this !

Was it helpful?

Solution

A big part of the interrupts' job is to allow the CPU to be interrupted by other devices (such as a network card that has received a packet). I find it's easier to understand this use case first.

When the network card needs to tell the CPU that is has received some data, it sends a number to the "interrupt pin" on the CPU. Typically that would be an 8-bit number. The number is called the "interrupt level".

The CPU is built in such a way to allow it to jump to some code to deal with the interrupt, and then return to what it was doing. This is built-in hardware so it has to be simple: there's a table that matches each interrupt level to the address of the function to call. That function is called an "Interrupt Service Routine". The location of this table is standardized, as you say, since it's the hardware that looks up in the table (so its address is hardcoded in the chip).

Servicing an interrupt just means to run the piece of code that is associated with the interrupt: in the case of the network card, that would mean to read the packet from the network card and copy it to memory (presumably, the memory on the network card itself is limited). You ask about "interrupt level identifier received as part of the interrupt cycle is used as an index into the interrupt vector". That's just another way to say what we just did: the signal from the card (the interrupt level) is used by the CPU as an index in a table ("the interrupt vector"). There, it finds the address of the code to run; that code was put there by the device driver for your network card (or perhaps by the OS).

When the ISR function returns, the CPU puts the registers back the way they were when it received the interrupt, so execution can resume as if nothing had happened. One way to think of this is that interrupts are a mechanism that allow the CPU to run several programs at once (your program and the network card driver).

The same concept of interrupts can also be used for "software interrupts", where instead of the signal coming from outside the CPU, it comes from the inside.

OTHER TIPS

Well, there certainly are a lot of questions in your question. Let me address one of them.

An interrupt is said to be serv, OH HANG ON, I HAVE TO LET THE DOG OUT., iced when the 'work' that the interrupt is complete.

In my silly sample case I was interrupted by the dog scratching at the door. I stopped what I was doing (in the middle of typing the word service), let the dog out, then resumed typing.

I 'serviced' the dogs interrupt request.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top