Interrupts types and classification Interrupt driven os interrupt handling Generic routine, interrupt vectors, interrupt chaining Interrupt implementation in the system Interrupt controller priorities, masks, reentrancy Silberschatz, Operating System


Different Interrupt Vectors for different devices



Download 182.84 Kb.
Page2/3
Date31.01.2017
Size182.84 Kb.
#13954
1   2   3

Different Interrupt Vectors for different devices

OS just takes the address and runs the routine.

Keyboard interrupt service routine


Mouse interrupt service routine


Timer

Interrupt service routine






The hardware analyzes the types of interrupts.

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

OS just takes the address and runs the routine.





Call all possible routines for each Group of device to see which one serves the interrupt.

Similar to Poll.




  • 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.

An example of x86 architecture interrupt vectors


Interrupt Vectors


Memory


Interrupt Vector Table (everything in hex)

00000000

00

00

01

00

Int 00h

- - - -
















00000010

00

00

24

00

Int 04h

- - - -
















00000020

00

00

17

00

Int 08h

00000024

00

00

12

00

Int 09h




Int 00h – Division by 0 handler

00000100
















- - - -
















00000180



















Int 04h – Overflow handler

00002400
















- - - -
















00002800



















Int 08h – Timer interrupt handler

00001700
















- - - -
















00001800



















Int 09h–Keyboard interrupt handler

00001200
















- - - -
















00001800



















User Program

00400000
















- - - -
















00410000





















INT 00H Division by 0

INT 01H


INT 02H

INT 03H


INT 04H Overflow

INT 05H


INT 06H

INT 07H


INT 08H Timer

INT 09H Keyboard




Interrupt Handler Routines










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.



Timer Interrupt occurs.

Program Counter is forcibly set to value from the interrupt table 00001700



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:



  1. 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.

  2. In your program:

    1. You have to save everything (mainly registers) you can damage in your subroutine.

    2. Perform the functions you want to do in your program.

    3. Recover saved information.

  3. 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




















  1. Save the original address 00001700 somewhere in User’s Handler Program.

  2. 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.



Recover everything which is saved.

Return from the handler







Interrupt implementation in the system


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 queue overflows and loses data.



Download 182.84 Kb.

Share with your friends:
1   2   3




The database is protected by copyright ©ininet.org 2024
send message

    Main page