0% found this document useful (0 votes)
3 views

Interrupts and Interrupt Handling- Revised

Class note

Uploaded by

kmomoh599
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Interrupts and Interrupt Handling- Revised

Class note

Uploaded by

kmomoh599
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Operating Systems – Events & Interrupts

• OS is event driven
– i.e. executes only when there is an interrupt, trap, or
system call

Event Types

Events

Interrupts Exceptions

Hardware Software Interrupts


Interrupts

1
Types of Interrupts and How to Handle Interrupts

Interrupts:
In early years of computing processor has to wait for the signal for processing, so processor has to
check each and every hardware and software program in the system if it has any signal to process.
This method of checking the signal in the system for processing is called polling method. In this
method, the problem is that the processor has to waste number of clock cycles just for checking the
signal in the system, in which case, the processor will become busy unnecessarily. If any signal
requires processing, the processor will take some time to process the signal due to the polling
process in action. So system performance also will be degraded and response time of the system will
also decrease.

So to get over this problem, engineers introduced a new mechanism. In this mechanism, the
processor will not check for any signal from hardware or software, but instead hardware/software will
only send the signal to the processor for processing. The signal from hardware or software should
have higher/highest priority in order for the processor to leave the current process and process the
signal of hardware or software. This mechanism of processing the signal is called interrupt of the
system.

What is an Interrupt?
Interrupt is a signal which has highest priority from hardware or software which processor should
process immediately.

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. Hardware interrupts
can be classified into two types they are
o Maskable Interrupt: The hardware interrupt which can be delayed when a much
highest priority interrupt has occurred to the processor.
o Non Maskable Interrupt: The hardware interrupt which cannot be delayed and
should be processed by the processor immediately.
2. Software Interrupts: Software interrupt can also divided in to two types. They are
o Normal Interrupts: the interrupts which are caused by the software instructions are
called normal interrupts
o 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.

Classification of Interrupts According to Periodicity of Occurrence:

3. Periodic Interrupt: If the interrupts occurred at fixed interval in timeline then that interrupts
are called periodic interrupts
4. Aperiodic Interrupt: If the occurrence of interrupt cannot be predicted then that interrupt
is called aperiodic interrupt.
Classification of Interrupts According to the Temporal Relationship with System Clock:

5. Synchronous Interrupt: The source of interrupt is in phase to the system clock is called
synchronous interrupt. In other words, interrupts which are dependent on the system clock.
Example: timer service that uses the system clock.
6. Asynchronous Interrupts: If the interrupts are independent or not in phase to the system
clock is called asynchronous interrupt.

Interrupt Handling:
We know that instruction cycle consists of fetch, decode, execute and read/write functions. After
every instruction cycle the processor will check for interrupts to be processed if there is no
interrupt is present in the system it will go for the next instruction cycle which is given by the
instruction register.

If there is an interrupt present then it will trigger the interrupt handler, the handler will stop the
present instruction which is processing and save its configuration in a register and load the
program counter of the interrupt from a location which is given by the interrupt vector table.
After
processing the interrupt by the processor interrupt handler will load the instruction and its
configuration from the saved register, process will start its processing where it’s left. This saving
the old instruction processing configuration and loading the new interrupt configuration is also
called as context switching.

The interrupt handler is also called as Interrupt service routine (ISR). There are different types of
interrupt handler which will handle different interrupts. For example for the clock in a system will
have its interrupt handler, keyboard it will have its interrupt handler for every device it will have
its interrupt handler.

The main features of the ISR are

 Interrupts can occur at any time they are asynchronous. ISR’s can call for asynchronous
interrupts.
 Interrupt service mechanism can call the ISR’s from multiple sources.
 ISR’s can handle both maskable and non maskable interrupts. An instruction in a program
can disable or enable an interrupt handler call.
 ISR on beginning of execution it will disable other devices interrupt services. After completion
of the ISR execution it will re initialize the interrupt services.
 The nested interrupts are allowed in ISR for diversion to other ISR.

Type of Interrupt Handlers:


1. First Level Interrupt Handler (FLIH) is hard interrupt handler or fast interrupt handler.
These interrupt handlers have more jitter while process execution and they are mainly
maskable interrupts
2. Second Level Interrupt Handler (SLIH) is soft interrupt handler and slow interrupt handler.
These interrupt handlers are having less jitter.
Polling vs. Interrupts
“Polling is like picking up your phone every few seconds to see if you
have a call. Interrupts are like waiting for the phone to ring.”

-Interrupts win if processor has other work to do and event response


time is not critical

-Polling can be better if processor has to respond to an event ASAP

-May be used in device controller that contains dedicated secondary


processor

INTERRUPT HANDLING

Maskable Device
Interrupt
CPU Controller
Device
Non-Maskable
(NMI) Device
Device

• Each device is given something like a wire (interrupt line)


that it can use to signal the processor.
• When interrupt signaled, processor executes a routine called
an interrupt handler to deal with the interrupt.
• No overhead when no requests pending.
Hardware Interrupt Handling

• Details are architecture dependent!


• Interrupt controller signals CPU that interrupt has occurred, passes
interrupt number
• Interrupts are assigned priorities to handle simultaneous
interrupts
• Lower priority interrupts may be disabled during service
• CPU senses (checks) interrupt request line after every
instruction; if raised, then:
• uses interrupt number to determine which handler to start
• interrupt vector associates handlers with interrupts
• Basic program state saved (as for system call)
• CPU jumps to interrupt handler
• When interrupt done, program state reloaded and program
resumes

You might also like