0% found this document useful (0 votes)
23 views3 pages

Chapter 4 Input and Output Devices and Interrupts

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

Chapter 4 Input and Output Devices and Interrupts

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

CHAPTER FOUR: INPUT AND OUTPUT DEVICES AND INTERRUPTS

Input Devices
An input device lets you communicate with a computer. They are used to enter
information and issue commands to the computer. Commands tell the computer to do
something, like save the file. A keyboard, mouse, scanner, digital camera, touch pads and
joystick are examples of input devices.
Output device
An output device displays information on a screen, creates printed copies or generates
sound. A monitor, printer, and speakers are examples of output devices.
Interrupts
An interrupt is a signal from some device or source seeking the attention of the
processor. The interrupt signal is sent along a control line to the processor, and the
currently executing program is suspended while control is passed to an interrupt service
routine.
Types of interrupt
The following are the different types of interrupt that could occur;
 Interrupts generated by the running process; the process might need to
perform I/O, obtain more storage or communicate with the operator
 I/O interrupts; these are initiated by the I/O hardware and signal to the CPU
that the status of a channel or device has changed. An I/O interrupt will occur
when an I/O operation is complete, when an error occurs, or when device is
made ready.
 Timer interrupts; these are generated by a timer within the processor, and allow
the operating system to perform certain functions at regular intervals. For
example, each user in a multi-user system may be allocated
 Program check interrupts; these are caused by various types of error such
as division by zero.
 Machine check interrupts; these are caused by malfunctioning hardware
Interrupt priorities
There is a special register in the CPU called the interrupt register. At the
beginning of each fetch-execute cycle, the interrupt register is checked. Each
bit of the register represents a different type of interrupt, and if a bit is set, the
state of the current process is saved and the operating system routes control
to the appropriate interrupt handler.
Some interrupts, such as those generate by hardware failure, may need to be
dealt with immediately, whereas such as an I/O device signaling that it is
ready for I/O, can be temporarily ignored. Interrupts are therefore assigned
priorities so that when two interrupts are received simultaneously, the one
with the highest priority is dealt with first. Only an interrupt with a higher
priority is allowed to interrupt the servicing of another.
Class of Interrupt Source of Interrupt Priority
Hardware failure Power failure-initiated when a decline in the 1
internal voltages is detected, giving the OS a few
milliseconds to close down as gracefully as
possible.
Program Arithmetic overflow 2
Division by zero 2
Attempt to execute an illegal machine instruction 2
Timer Generated by internal clock within the processor 3
I/O I/O device signals normal completion or the 4
occurrence of an error condition
The Interrupt Handler
What happens when, for example, a key on the keyboard is pressed, thus
generating an interrupt? A small program called an interrupt service routine
(ISR) or interrupt handler is executed to transfer the character value f the key
pressed into main memory. A different ISR is provided for each different
source of interrupt. A typical sequence of actions when an interrupt occurs
would be:
1. The current fetch-execute cycle is completed
2. The contents of the program counter, which points to the next instruction of the
program to be executed, must be stored away safely so it can be restored after
servicing the interrupt.
3. The contents of other registers used by the user program are stored away
safely for later restoration
4. The source of the interrupt is identified
5. Interrupts of a lower priority are disabled
6. The program counter is loaded with the start address of the relevant
interrupt service routine.
7. The interrupt service routine is executed
8. The saved values belonging to the user program for registers other than the
program counter are restored to the processor’s registers
9. Interrupts are re-enabled
10. The program counter is restored to point to the next instruction to be
fetched and executed in user program
Chapter review questions
1. Give four different types of event that may cause an interrupt
2. When data is being sent to a printer an interrupt may occur. State two reasons why
an interrupt may occur in this case
3. Describe the role of priorities in the handling of interrupts

You might also like