Introduction

  • On the occurrence of an interrupt, an interrupt request (in the form of a signal) is issued to the CPU. The CPU on receipt of interrupt request suspends the operation of the currently executing program, saves the context of the currently executing program and starts executing the program which services that interrupt request. This program is also known as interrupt handler. After the interrupting condition/ device has been serviced the execution of original program is resumed.

Definition

  • Interrupt is an exceptional event that causes CPU to temporarily transfer its processing control from currently executing program to a different program which provides service to the exceptional event.
  • An interrupt is the interruption of the execution of an ongoing user program. The execution of user program resumes as soon as the interrupt processing is completed. Therefore, the user program does not contain any code for interrupt handling. 
  • Interrupt is a process of creating a temporary halt/pause of currently executing program and allows peripheral devices to access the microprocessor.

Features

  • An interrupt is also acknowledged by the CPU when it has completed the currently executing instruction. 
  • The occurrence of Interrupt is known by the CPU using the status of Interrupt flag register.
  • The interrupt is performed by the processor and the operating system, which in turn are also responsible for suspending the execution of the user program, and later after interrupt handling, resumes the user program from the point of interruption.
  • There are more than 256 software and hardware interrupts in 8086 microprocessor.
  • Interrupt Working Mechanism : Once a CPU knows that an interrupt has occurred then –
    • The CPU must find out the source of the interrupt and checked why the interrupt has occurred that includes not only the device but also why that device has raised the interrupt. Once the interrupt condition is determined the necessary program called ISRs (Interrupt servicing routines) must be executed such that the CPU can resume further operations. Thus, on occurrence of an Interrupt the related ISR is executed by the CPU. 
    • The CPU then acquires the address of the interrupt service routine, which are stored in the memory (in general).
    • When Interrupt occurs then the program, the CPU was executing before the interrupt was interrupted/suspended till the CPU executes the Interrupt service program and the context of this program is to be saved in the memory. It is the operating system that before an interrupt service routine is executed the previous content of the CPU registers should be stored, such that the execution of interrupted program can be restarted without any change from the point of interruption. Therefore, at the beginning of interrupt processing the essential context of the processor is saved either into a special save area in main memory or into a stack. This context is restored when the interrupt service routine is finished, thus, the interrupted program execution can be restarted from the point of interruption.
    • Finally, the CPU executes the interrupt service routine till the completion of the routine. A RETURN statement marks the end of this routine. After that, the control is passed back to the interrupted(previous) program.
  • Interrupt Servicing Routines(ISR) :
    • The ISRs are pre-defined programs written for specific interrupt conditions.
    • Microprocessor responds to arised interrupts with an ISR, which is really a short program or subroutine to instruct the microprocessor, how to handle the arised interrupt.
  • Interrupt Vectors Table(IVT) :
    • IVT are also known as Interrupt Pointers Table.
    • IVT is a 1KB memory size table which contains the list of more than 256 interrupts index address as pointer numbered from 0 to 255. The number assigned to an interrupt pointer is known as type of that interrupt. For example, Type 0, Type 1, Type 2,………..Type 255 interrupt.
  • Interrupt when occurs, is handled and operated successfully through Interrupt cycle. In the interrupt cycle, the responsibility of the CPU/Processor is to check whether any interrupts have occurred checking the presence of the interrupt signal. In case, no interrupt needs service, the processor proceeds to the next instruction of the current program. In case an interrupt needs servicing then the interrupt is processed as per the following way –
    • Suspend the execution of current program and save its context.
    • Set the Program counter to the starting address of the interrupt service routine of the interrupt acknowledged.
    • The processor then executes the instructions in the interrupt-servicing program. The interrupt servicing programs are normally part of the operating system.
    • After completing the interrupt servicing program the CPU can resume the previous program it has suspended.

Reason of Interrupts

  • An interrupt may be generated by a number of sources, which may be either internal or external to the CPU.
  • Some common factors that influence interrupt are –
Interrupt are generated by executing the program itself (called traps)
  • When program code contains division by zero.
  • The number exceeds the maximum allowed size.
  • Attempt of executing an illegal/privileged instruction.
  • Trying to reference memory location other than allowed for that program.
Interrupt generated by clock (pulse) in the processor Generally used on expiry of time allocated for a program, in multiprogramming operating systems.
Interrupts generated by I/O devices and their interfaces
  • Request of starting an Input/Output operation.
  • Normal completion of an Input/Output operation.
  • Occurrence of an error in Input/Output operation.
Interrupts on Hardware failure
  • When power supply fails.
  • When memory parity error arise.

                  

Advantages

  • It increases the processing efficiency of CPU.
  • It decreases the waiting time of a process.

Types of Interrupts

  • Broadly, Interrupts are of two types: 

(i)Hardware interrupt and (ii) Software interrupt.

(i)Hardware interrupt

    • The hardware interrupt caused by the interrupt request signal arised from peripheral devices/hardware of the system.

(ii) Software interrupt

    • The software interrupt occurrs by executing a dedicated instruction/segment of program code/by internal abnormal conditions such as overflow; division by zero etc.
    • A programmer can also create an interrupt as per the requirement of the program for microprocessor by inserting INT instruction at the desired point in the program while debugging a program.
    • Example of software interrupts are:
      • TYPE 0 : division by zero.
      • TYPE 1 : single step execution for debugging a program.
      • TYPE 2 : power failure condition.
      • TYPE 3 : break point interrupt.
      • TYPE 4 : overflow interrupt.

Use/Application of Interrupts

  • Interrupts are actually a useful mechanism because it improves the efficiency of processing. As we know that almost all the external devices are comparatively slower than the processor, therefore, in a typical system, a processor has to continually test whether an input value has arrived or a printout has been completed, in turn wasting a lot of CPU time. With the interrupt facility, CPU is freed from the task of testing status of Input/Output devices and can do useful another processing during this time, thus increasing the processing efficiency.

Loading


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.