0% found this document useful (0 votes)
10 views4 pages

Ca 5

An interrupt is a signal to the CPU to temporarily halt normal processing and execute an Interrupt Service Routine (ISR) to address high-priority events. There are two types of interrupts: hardware interrupts, triggered by external devices, and software interrupts, caused by exceptional conditions or specific instructions. Interrupts improve processing efficiency by allowing the CPU to continue executing other tasks while waiting for slower I/O operations to complete.

Uploaded by

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

Ca 5

An interrupt is a signal to the CPU to temporarily halt normal processing and execute an Interrupt Service Routine (ISR) to address high-priority events. There are two types of interrupts: hardware interrupts, triggered by external devices, and software interrupts, caused by exceptional conditions or specific instructions. Interrupts improve processing efficiency by allowing the CPU to continue executing other tasks while waiting for slower I/O operations to complete.

Uploaded by

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

Interrupts:

An interrupt is a request to the CPU to suspend normal processing and temporarily divert
the flow of control through a new program. This new program to which control is
transferred is called an Interrupt Service Routine or ISR. Another name for an ISR is an
Interrupt Handler.

In systems programming, an interrupt is a signal to the processor emitted by hardware or


software indicating an event that needs immediate attention. An interrupt alerts the processor
to a high-priority condition requiring the interruption of the current code the processor is
executing. The processor responds by suspending its current activities, saving its state, and
executing a function called an interrupt handler (or an interrupt service routine, ISR) to deal
with the event. This interruption is temporary, and, after the interrupt handler finishes, the
processor resumes normal activities.
There are two types of interrupts:
 Hardware interrupts
 Software interrupts.
Hardware interrupts are used by devices to communicate that they require attention from
the operating system. Internally, hardware interrupts are implemented using electronic
alerting signals that are sent to the processor from an external device, which is either a part of
the computer itself, such as a disk controller, or an external peripheral. For example, pressing
a key on the keyboard or moving the mouse triggers hardware interrupts that cause the
processor to read the keystroke or mouse position. Hardware interrupts are asynchronous and
can occur in the middle of instruction execution, requiring additional care in programming.
The act of initiating a hardware interrupt is referred to as an interrupt request(IRQ).

A software interrupt is caused either by an exceptional condition in the processor itself, or a


special instruction in the instruction set which causes an interrupt when it is executed. The
former is often called a trap or exception and is used for errors or events occurring during
program execution that are exceptional enough that they cannot be handled within the
program itself. For example, if the processor's arithmetic logic unit is commanded to divide a
number by zero, this impossible demand will cause a divide-by-zero exception, perhaps
causing the computer to abandon the calculation or display an error message. Software
interrupt instructions function similarly to subroutine calls and are used for a variety of
purposes, such as to request services from low-level system software such as device drivers.
For example, computers often use software interrupt instructions to communicate with
the disk controller to request data be read or written to the disk.
I/O Software System Layers:

The above diagram shows the various software layers related to I/O. At the bottom lies
the actual hardware itself, i.e. the peripheral device. The peripheral device uses the
hardware interrupts to communicate with the processor. The processor responds by
executing the interrupt handler for that particular device. The device drivers form the
bridge between the hardware and the software. The operating system uses the device
drivers to communicate with the device in a hardware independent fashion, e.g., the

operating system need not care for a specific brand of CRT monitors, or keyboards, the
specific device driver written for that monitor or keyboard will act as an intermediary
between the operating system and the device. It would be clear from the previous
statement that the operating system expects certain common functions from all brands of
devices in a category. Actually implementing these functions for each particular brand or
vendor is the responsibility of the device driver. The user programs run at top of the
operating system.

Why Interrupt:

Interrupts are provided primarily as a way to improve


processing efficiency. For example, most external devices are
much slower than the processor. Suppose that the processor is
transferring data to a printer using the instruction cycle
scheme. After each write operation, the processor must pause
and remain idle until the printer catches up. The length of this
pause may be on the order of many hundreds or even
thousands of instruction cycles that do not involve memory.
Clearly, this is a very wasteful use of the processor. Figure 3.7a
illustrates this state of affairs. The user program performs a
series of WRITE calls interleaved with processing. Code
segments 1, 2, and 3 refer to sequences of instructions that do
not involve I/O. The WRITE calls are to an I/O program that is a
system utility and that will perform the actual I/O operation.
The I/O program consists of three sections:

• A sequence of instructions, labelled 4 in the figure, to prepare


for the actual I/O operation. This may include copying the data
to be output into a special buffer and preparing the parameters
for a device command.

The actual I/O command. Without the use of interrupts, once


this command is issued, the program must wait for the I/O
device to perform the requested function (or periodically poll
the device).The program might wait by simply repeatedly
performing a test operation to determine if the I/O operation is
done.

• A sequence of instructions, labelled 5 in the figure, to


complete the operation. This may include setting a flag
indicating the success or failure of the operation.
Because the I/O operation may take a relatively long time to complete, the I/O program is
hung up waiting for the operation to complete; hence, the user program is stopped at the
point of the WRITE call for some considerable period of time.

You might also like