Advantage: For large amount of interrupts the process is fast.
Disadvantage: Complex hardware. Not flexible.
The software analyzes the types of interrupts.
Disadvantage: For large amount of interrupts the process will be slow.
Advantage: There is no special hardware created for different types of interrupts.
The Software is flexible for changes.
(Interrupt Chaining)
The purpose of a vectored interrupt mechanism is to reduce the need for a single interrupt handler to search all possible sources of interrupts to determine which one needs service.
In practice, however, computers have more devices (and, hence, interrupt handlers) than they have address elements in the interrupt vector.
A common way to solve this problem is to use the technique of interrupt chaining, in which each element in the interrupt vector points to the head of a list of interrupt handlers.
When an interrupt is raised, the handlers on the corresponding list are called one by one, until one is found that can service the request.
Different Interrupt Vectors for different device Groups
This structure is a compromise between the overhead of a huge interrupt table and the inefficiency of dispatching to a single interrupt handler.
How interrupts occur and how they are serviced The three different types of Interrupts have a single way of hardware implementation. When the interrupt occurs then the Program Counter is forcibly set to the New Address – The Interrupt Handler Routine Address.
Then the Software (Operating System) takes care of the interrupt.
Below is the Intel X86 like computers memory picture which shows haw are organized the interrupt vectors and handler programs.
Let’s suppose we run the Internet Browser which downloads something for us.
During that download (or any other action performing by other programs) the timer on windows taskbar is renewed independently. We suppose that we work only with Internet Browser. The time is changed in background mode without any apparent program participation.
It is done by interrupt mechanism and below is shown how the interrupt is handled when it occurs.
Int number x 4 = 08h x 4h = 20h 00000020h= 00001700
User Program
lw $8, Var1
lw $9, Var2
add $10,$8,$9
add $10, ….
Timer Interrupt Handler Program
Address - 00001700
Save everything possible which could be used in this subroutine
Serve the Timer Interrupt:
See if there is need to change the time on the taskbar and change it.
Recover everything which is saved.
Return from the handler
If you want to write your program to serve the Timer Interrupt then you have to do the following steps:
Change the Interrupt Table and set Your Program Handler Address (00002900) instead of Original Program Handler Address (00001700). Then after the interrupt your program will get the control.
In your program:
You have to save everything (mainly registers) you can damage in your subroutine.
Perform the functions you want to do in your program.
Recover saved information.
Return by Original Program Handler Address (00001700). Now the Original Program will perform its function without any suspect that the other program has been run before it.
Memory
Interrupt Vector Table (everything in hex)
00000000
00
00
01
00
Int 00h
- - - -
00000010
00
00
24
00
Int 04h
- - - -
00000020
00
00
29
00
Int 08h
00000024
00
00
12
00
Int 09h
Int 08h – Timer interrupt handler
00001700
- - - -
00001800
Timer Interrupt User’s Handler
00002900
- - - -
00001700
- - - -
00002A00
Save the original address 00001700 somewhere in User’s Handler Program.
Set the address of User’s Handler 00002900 into the 00000020 address (Timer Interrupt Vector)
Timer Interrupt occurs.
Program Counter is forcibly set to value from the interrupt table 00002900
Int number x 4 = 08h x 4h = 20h 00000020h= 00002900
User Program
lh $8, Var1
lh $9, Var2
add $10,$8,$9
add $10, ….
User Interrupt Handler Program
Address - 00002900
Save everything possible which could be used in this subroutine
Serve the Timer Interrupt as User needs:
Recover everything which is saved.
Return from the User Interrupt Handler by the Original Interrupt Handler Address 00001700
Timer Interrupt Handler Program
Address - 00001700
Save everything possible which could be used in this subroutine
Serve the Timer Interrupt:
See if there is need to change the time on the taskbar and change it.
This basic interrupt mechanism enables the CPU to respond to an asynchronous event, as when a device controller becomes ready for service. In a modern operating system, however, we need more sophisticated interrupt handling features. 1. We need the ability to defer interrupt handling during critical processing.
2. We need an efficient way to dispatch to the proper interrupt handler for a device without first polling all the devices to see which one raised the interrupt.
3. We need multilevel interrupts, so that the operating system can distinguish between high- and low-priority interrupts and can respond with the appropriate degree of urgency.
In modern computer hardware, these three features are provided by the CPU and by the interrupt-controller hardware.
Interrupt Priority.
The trap (system calls) is given a relatively low interrupt priority compared with those assigned to device interrupts
Executing a system call on behalf of an application is less urgent than servicing a device controller before its FIFO queueoverflows and loses data.