Interrupts: For Example Let Us Take A Task That Involves Two Activities
Interrupts: For Example Let Us Take A Task That Involves Two Activities
Interrupts: For Example Let Us Take A Task That Involves Two Activities
Our processor repeatedly keeps on checking for the SIN and SOUT bits for the synchronization
in the program. Hence, the processor does not do any things useful other than running the
infinite loop. To avoid this situation input/output devices can have the concept of interrupts .
When the input/output device is ready it could signal the processor on a separate line called
interrupt request line. On receiving the interrupt the processor reads the input output device
and hence removing the infinite loop waiting mechanism.
Repeat the above two steps several times in the program, let the program contain 2 routines
COMPUTE and PRINT routine.
Method #1 :
The COMPUTE routine passes N lines to the PRINT routine and the PRINT routine then prints
the N lines one by one on a printer. All this time the COMPUTE routine keeps on waiting and
does not do anything useful.
Method #2 :
The COMPUTE routine passes N lines to the PRINT routine. The PRINT routine then sends
one line to the printer and instead of printing that line it execute itself and passes the control to
the COMPUTE routine . The COMPUTE routine continuous it activity, once the line has been
printed the printers sends an interrupt to the processor of the computer. At this point the
COMPUTE routine is suspended and the PRINT routine is activated and the PRINT routine
send second line to the printer so that the printer can keep on printing the lines and the process
continues.
TYPES OF INTERRUPTS
Although interrupts have highest priority than other signals, there are many type of interrupts
but basic type of interrupts are ->
1. Hardware Interrupts: If the signal for the processor is from external device or
hardware is called hardware interrupts.
Example: from keyboard we will press the key to do some action this pressing of key in
keyboard will generate a signal which is given to the processor to do action, such interrupts are
called hardware interrupts.
• Maskable Interrupt: The hardware interrupts which can be delayed when a much
highest priority interrupt has occurred to the processor.
• Non Maskable Interrupt: The hardware which cannot be delayed and should process
by the processor immediately.
2. Software Interrupts: Software interrupt can also divided in to two types they are ->
• Normal Interrupts: the interrupts which are caused by the software instructions are
called software instructions.
• Exception: unplanned interrupts while executing a program is called Exception. For
example: while executing a program if we got a value which should be divided by zero
is called a exception.
1. When you give some input it will perform computations and produces output but
meanwhile you can interact with the system by interrupting the running process or you
can stop and start another process
INTERRUPT HARDWARE
Many computers have facility to connect two or more input and output devices to it like laptop
may have 3 USB slots. All these input and output devices are connected via switches as shown
-
So there is a common interrupt line for all N input/output devices and the interrupt handling
works in the following manner ->
1. When no interrupt is issued by the input/output devices then all the switches are open
and the entire voltage from Vdd is flown through the single line INTR and reaches the
processor. Which means the processor gets a voltage of 1V.
2. When the interrupt is issued by the input/output devices then the switch associated with
the input/output device is closed, so the entire current now passes via the switches
which means the hardware line reaching the processes i.e INTR line gets 0 voltage.
This is an indication for the processor that an interrupt has occurred and the processor
needs to identify which input/output device has triggered the interrupt
3. The value of INTR is a logical OR of the requests from individual devices.
4. The resistor R is called as a pull up resistor because it pulls the line voltage to high
voltage state when all switches are open( no interrupt state).
Because of the above reasons it may be some time necessary to disable the interrupt and enable
it later on in the program. For this reason some processor may provide special machine
instructions such as interrupt enable an interrupt disable that performs these tasks.
Let’s assume that an interrupt has occurred and the interrupt service routine is about to be
executed. The interrupt line is still high and it may go low only when the interrupt routine is
returned. This may take some time during which the processor may think that some more
interrupts have arrived and needs to be scheduled first so that the interrupt service routine do
not leads to an infinite loop of interrupts.
• Method 1 : As soon as the interrupt service routine is entered all interrupts are disabled.
The interrupts are enabled only while exiting the interrupt service routine. Also note
that the program written for the interrupt service routine has to enable and disable the
interrupts in this case. This is done explicitly by the programmer.
• Method 2 : In case of simple processor, the processor can disable the interrupts when
the interrupt service routine is entered. It will enable the interrupt when the interrupt
service routine is about to exit. This method is different from first method as in first
method we had to explicitly write the program for the interrupt service routines to
enable and disable the interrupts, where is in this case the processor has inbuilt
mechanism to perform this task.
The status register can be used to identify the device using an interrupt. When a device raises
an interrupt it will set a specific bit to one . That bit is called IRQ(Interrupt ReQuest) .
IRQs are hardware lines over which devices can send interrupt signal to the microprocessor
When you add a new device to a PC you sometime need to set its IRQ number by setting a
DIP switch. Earlier the KIRQ bit is set to 1 when an interrupt is taken from the keyboard and
the DIRQ bit it was set to 1 while displaying an output.
DISADVANTAGES -> A lot of time spent in checking for the IRQ bits of all the devices,
considering that most of devices are generating interrupts at a random time.