Presentation is loading. Please wait.

Presentation is loading. Please wait.

Interrupts.

Similar presentations


Presentation on theme: "Interrupts."— Presentation transcript:

1 Interrupts

2 Polling vs. Interrupts Two ways the operating system can be notified of pending data: Polling Interrupts

3 Polling The operating system continually asks devices if they have data pending Disadvantages: Polling overhead takes a significant amount of the CPU’s time If the CPU is not fast enough, or has its time diverted too much to other tasks, data can easily be lost

4 Interrupts Operating system waits for devices to notify it of pending data Disadvantage – requests for data and reading of data happen in separate functions, which can be harder to maintain and keep stable Advantage – operating system can concentrate on other tasks until the data ready

5 Good Ol’ Intel Everything but the CPU, motherboard, and memory are peripheral devices – modem, hard drive, mouse, keyboard, video card, Ethernet card, real-time clock (to name a few) Every peripheral device has an assigned IRQ and range of ports

6 Good Ol’ Intel (cont.) IRQ and ports
Direct lines to the CPU for direct communication IRQ stands for Interrupt ReQuest, and is the mechanism the device uses to interrupt the CPU The ports are a mechanism for sending and receiving data Example – keyboard (IRQ 01, ports 60h, 64h) When a device is ready to send or receive data, it sends an interrupt request, which notifies the CPU that the device is ready for communication through the ports

7 Interrupt Vector Table
Each IRQ needs some routine to handle hardware interrupts First 1024 bytes of memory is the Interrupt Vector Table

8 Interrupt Vector Table (cont.)
256 far pointers contain the addresses to Interrupt Service Routines When a hardware interrupt occurs, the CPU clears the if and tf and executes the following (pseudo-) instructions immediately: pushf call [0000:00xx] Every ISR ends with the instruction iret, which pops the flags and cs:ip

9 Software Interrupts The Interrupt Vector Table is available for more than just hardware A program can invoke in interrupt – this is a software interrupt The int instruction more-or-less simulates a hardware interrupt Most interrupts are written to be called from hardware or software, but not both Most software interrupts expect registers to hold meaningful data by the time they are called

10 DOS Software Interrupts
Exist to provide a consistent interface to operating system functions Example: mov ah, 4Ch mov al, [exCode] int 21h DOS uses two interrupts – 20h and 21h For 21h interrupts, register ah contains the function number, and the other registers contain values specific to the function


Download ppt "Interrupts."

Similar presentations


Ads by Google