You are on page 1of 9

Operating Systems

Interrupt Handling
By
Ms. Zubaria Noureen
Interrupt and Traps
• The occurrence of an event is usually signaled
by an interrupt from either the hardware or the
software.
• Stop one process and execute another.
• A request from a hardware device or a
software program for immediate service by the
processor. Answer
the Phone
.
.
.

Resume
Interrupt
• When the CPU is interrupted, it stops what it is doing and immediately transfers
execution to a fixed location.
• The fixed location usually contains the starting address where the service routine for
the interrupt is located.
• The interrupt service routine executes; the CPU resumes the interrupted
computation
• Interrupt transfers control to the interrupt service routine generally,
through the interrupt vector, which contains the addresses of all the
service routines
• Interrupt architecture must save the address of the interrupted instruction
Control Flow: Program and Interrupt Handler
• User program is interrupted after
ith instruction
• Interrupt handling service routine
takes over ( Interrupt service
Routine-ISR)
• User program continues with
(i+1)th instruction
Types of Interrupts
• Hardware Interrupts
Hardware may trigger an interrupt at any time by sending a signal to
the CPU e.g. press keyboard button , mouse click, power button.
• Software Interrupts
Software may trigger an interrupt by executing a special operation
called a system call. e.g. read, write, open file from secondary memory.
• Vectored Interrupts
Fixed location or address is given to locate content.
• Non-Vectored Interrupts
No fixed location or address is given to locate content. E.g. trap
Example: Starting an I/O Device
I/O without Interrupts
• Need to wait possibly long for I/O to finish
– Processor usually much faster than I/O
devices

• Write handover control to I/O device


– No further processing possible

• Continuously verify status or even contact the


I/O device
I/O With Interrupts
• Write, only triggers the I/O
command

• Program can continue while


I/O operation is in progress

• Interrupt occurs when I/O


operation is finished or something
went wrong
Test Your Knowledge
• How does the operating system ensure that critical tasks are not
delayed by non-critical interrupts?

• What techniques are used to minimize interrupt overhead in


operating systems?

You might also like