What is the purpose of having interrupts in computers?
interrupts done to improve processing efficiency
Explain what is meant by: Program interrupt, Timer interrupt, 1/O interrupt, and Hardware failure interrupt.
Program |
by condition occurs during execution of the instruction e.g., arithmetic overflow, division by zero. |
Timer |
by a timer within the processor to allow the operating system to perform function on a regular basis |
I/O |
by an I/O controller, to signal normal operation or to signal error condition |
Hardware failure |
by a failure such as power failure |
Program Flow of Control (without Interrupts)
Suppose that the processor is transferring data to a printer. After, each write operation, the processor must pause and remain idle until the printer catches up (wasting time of processor with no memory use).
The user program contains series of system calls in form of WRITE calls interleaved with code processing segments,2,3 without use of I/O.
The I/O program consists of:
- The preparation code, a sequence of instructions(4) to prepare for the I/O operation ( copy data to buffer and prepare the device).
- The actual I/O command where the processor waits for the I/O device to perform the operation with periodic testing instructions.
- A sequence of instructions (5) to complete the operation with operation success/failure flag.
Program Flow of Control with Interrupts & short I/O wait
- With interrupts, processor can execute other instructions while an I/O operation is in progress.
- The I/O program contains the preparation code & the actual I/O command. After these few instructions have been executed, control returns to the user program
- Short time means, time for I/O operation is less than the time required to complete the execution of instructions between write operation in the user program (Time of I/O operation < 2b or 3b)