Program Interrupts

In the program control transfer, the computer keeps checking the flag bits, and when it finds anyone set, it initiates an information transfer. The difference of information flow rate between the computer and that of the input-output device makes this type of transfer inefficient.

The computer is wasting time while checking the flag instead of doing some other useful processing task.

An alternative to the programmed control procedure is to let the external device inform the computer when it is ready for the transfer. In the mean time the computer can be busy with other tasks. This type of transfer uses the interrupt facility. While the computer is running a program, it does not check the flags.

However, when a flag is set, the computer is momentarily interrupted from proceeding with the current program and is informed of the fact that a flag has been set. The computer deviates momentarily from what it is doing to take care of the input output transfer. It then returns to the current program to continue what it was doing before the interrupt.

Thus interrupt is external triggered and the service routine is provided by operating system. The program interrupt provides transfer of program control form a currently running program to another service program. This service program is similar to subroutine. It occurs as a result of external or internal generated request. The control returns to the original after execution of the service program.

Program interrupt is quite similar to a subroutine call except:

  1. Interrupt is usually involved by an external or internal signal rather than form within the program
  2. The address of interrupt service program is determined by the hardware rather than form the address field of an instruction. (Interrupt carries the address of the hardware)
  3. Interrupt procedure usually stored all the information necessary to define the state of the CPU rather than storing only the program counter (PC). (Code segment and data segment are also stored).

In some computers there are two modes of operations, the user mode and the supervisor mode. For each mode there will be two sets of each register denoting the current state of program. When interrupt is called the system transfers control to the supervisor mode that will simplify the retaining of the previous state of program.

In a typical application a number of I/O devices are attached to the computer, with each device being able to originate an interrupt request. It is the task of the interrupt system to identify the source of the interrupt and to decide which device to serve first. A priority interrupt is a system that establishes a priority over the various sources to determine which condition is to be serviced first when two or more requests arrive simultaneously. The system may also determine which conditions are permitted to interrupt the computer while another interrupt is being serviced.

Types of Interrupts:

There are three major types of interrupts that cause a break in the normal execution of program. They can be classified as:

  1. External interrupts

  2. Internal interrupt

  3. Software interrupt

External interrupts:

External interrupts come form input-output (I/O) devices, from a timing device, from a circuit monitoring the power supply, or from any external sources. The external interrupts are caused by I/O device requesting transfer of data, I/O device finished transfer of data, elapsed time of an event, or power failure.

Internal interrupts:

Interrupts that arise from illegal or erroneous use of an instruction or data are called internal interrupts. They are also called traps. The example of internal interrupts is condition of register overflow; attempt to divide by zero, an invalid operation code, stack overflow, and protection violation. These error conditions usually occur as a result of a premature termination of the instruction execution.

The difference between the internal and external interrupts is that the internal interrupt is initiated by some exceptional condition caused by the program itself rather than by an external event. Internal interrupts are synchronous with the program while external interrupts are asynchronous.

If the program is rerun, the internal interrupts will occur in the same place each time. External interrupts depends on external conditions that are independent of the program being executed at the time.

Differentiate Between External and Internal Interrupt:

External interrupt Internal interrupt
1. Initiated by external events 1. Initiated by exceptional conditions.
2. Asynchronous with the program 2. Synchronous with program.
3. If program is rerun, external interrupt won’t occur in the same place because it depends on external conditions. 3. If program is rerun, internal interrupts will occur in the same place.

Software interrupts:

A software interrupt is initiated by executing an instruction. Software interrupt is special call instruction that behaves like interrupt rather than a subroutine call. The programmer to initiate an interrupt procedure at any desired point in the program can use it. The most common use of software interrupt is associated with a supervisor call instruction.

comments powered by Disqus