Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 39

CHAPTER 5

Interfacing and
Communications
-HANDSHAKING, BUFFERING,
PROGRAMMED I/O, INTERRUPT
Introduction

• Peripheral devices demand the attention of


microprocessor at various and predictable
times during normal program execution.
• Several techniques are combined to resolve the
problem of synchronizing and handling I/O
between a variety of different I/O devices
I/O Fundamentals
• I/O devices cannot connect directly to the CPU
because:
• The formats required for different devices are
different.
– Some require single piece of data
– Some require a block of data
– Some expect data sequentially
– Some expect data parallel
• Incompatibilities in speed make
synchronization difficult.
3
Therefore, there must be..
• A means to individually address different devices.
• A way for peripheral device to initiate communication
with CPU.
• An efficient means of transferring data directly between
I/O and memory.
• Buses that support high data transfer rates
• Means for handling devices with different control
requirements.
--> Thus, I/O module is needed.
I/O Interfaces/Modules

Is necessary because:
•Different formats required by the devices
•Incompatibilities in speed between the devices
and the CPU make synchronization difficult
•Burst of data vs streaming data
•Device control requirements that would tie up
too much CPU time
Simple I/O Configuration
More Complex I/O Module
I/O Module Functions
• Recognizes messages from device(s) addressed to it
and accepts commands from the CPU
• Provides a buffer where the data from memory can be
held until it can be transferred to the device
• Provides the necessary registers and controls to
perform a direct memory transfer
• Physically controls the device
• Copies data from its buffer to the device/from the
CPU to its buffer
• Communicates with CPU
I/O Techniques

• Buffering
• Handshaking
• Programmed I/O
– CPU controlled I/O
• Interrupt Driven I/O
– External input controls
• Direct Memory Access Controllers
– Method for transferring data between main
memory and a device that bypasses the CPU
Buffering
• A method where a buffer holds the data and
release a part of it at particular times.
• A region of memory used to temporarily hold
data while it is being moved from one place to
another.
• Buffers can be implemented in either hardware
or software, but majority of buffers are
implemented in software
Handshaking
• A brief back-and-forth series of requests and
acknowledgements to request a connection.
• If the negotiation is successful, a connection is
opened.
• This connection is logically a full-duplex
connection.
• A web browser application use this technique
to establish connection in the Internet
Programmed I/O
• I/O data and address registers in CPU (CPU
controlled I/O).
• One word transfer per I/O instruction
• Address information for each I/O device included (for
multiple devices).
• Full instruction fetch/execute cycle (slow).
• Primary use:
– keyboards
– communication with I/O modules (i.e.. the transmission
of commands through a network I/O module or modem)
Programmed I/O Example
Interrupt Driven I/O
• Peripheral devices may demand the attention of the
microprocessor during normal program execution
• What is an interrupt?

“A call for the microprocessor to interact or


service the interrupting unit”

• The interrupt will cause the computer to suspend the


program being executed and jump into a special
interrupt processing program
Interrupt

• Signal that causes the CPU to alter its normal


flow on instruction execution
– frees CPU from waiting for events
– provides control for external input
Polling Process (before interrupt)
• Microprocessor would do routine checkup for
the peripheral devices to see if its need service
• A better system is an interrupt process where it
allows the processor to continue normal
sequential execution until there is a specially
needed attention.
Interrupt Lines
• It would be desirable to interrupt the normal flow of a
program to react to/service a special event
• Modern computers provide interrupt capability by
providing one or more special control lines known as
Interrupt Line to the processor
• PC may contains as many as thirty-two interrupt lines
( IRQ0 to IRQ31)
Types Of Interrupt
• There are two type of interrupts
– Hardware interrupt – this interrupt is being
sent by the peripheral devices to indicate
certain conditions such as keyboard entry,
printing problem, and power failure
– Software interrupt – modern CPU has a set
of instructions to simulates an interrupt for
examples are HALT and INT
Interrupt Services
• The message sent through the IRQ line will
cause an interrupt
• The interrupt will cause the computer to
suspend the program being executed and jump
to a special interrupt processing program
• Interrupt Handler Program is the action taken
by the microprocessor when an interrupt
occurs
• This is also known as interrupt routine
Servicing The Interrupt
• There are four steps taken by microprocessor
to handle an interrupt:
– The microprocessor finished the current instruction
until the end of an instruction cycle
– Normal operation is suspended
– The microprocessor jumps to the location in
memory where the interrupt service routine has
been stored and executes the routines
– When the interrupt routines complete, it would
return control to the interrupted program
Servicing an Interrupt
Categories of Interrupt
• Two categories:
– Maskable
– Non-maskable
• Maskable – interrupt that can be selectively
disabled.
– Not accepted.
• Non-maskable – interrupt that is never disabled.
– Will always be acknowledged and accepted. E.g.
Power failure.
Multiple Interrupts
• There are many different types input and output
devices and event indicators connected to the
interrupt lines
• Multiple interrupts can occur from time to time
• Two different processing methods used to determine
which devices initiated the interrupt are
– vectored interrupt
– polling
Vectored Interrupt

• The address of the interrupting devices is


included as part of the interrupt
• The vectored interrupt is faster than
polling but requires additional hardware
to implement
Vectored Interrupts
Polling

• It provides general interrupt that is shared by


all devices
• There is a common branch address for all
interrupt
• The program that take care of interrupt begin
at branch address and poll the interrupt sources
in sequence to identify the interrupting devices
Polled Interrupts
Handling Multiple Interrupts

• Can be handled by assigning priorities to each


interrupt
• A higher priority interrupt will be allowed to
interrupt a lower priority interrupt
• Lower priority interrupt will have to wait until
a higher interrupt is completed
Establishing Priority

• Most computer system allows the system manager to


establish priorities for various interrupt
• The three methods to establish priorities:
– Logical way – time-sensitive situation has a high priority
– Hardware – physical location of the devices
– Software – assigning a priority number to each interrupts
Servicing Multiple Interrupts
Usage of Interrupt

• The way which an interrupt is used depend on


the nature of the devices
• There are several ways in which interrupt are
used:
– As an external event notifier
– As a completion signal
– As a means of allocating CPU time
– As an abnormal event indicator
External Event Notifier
• To indicate some external devices require
action
• An example is keyboard input
Completion Signal

• To control the flow of data to an output device


• Interrupt serves to notify the computer
completion of a particular course of action
• An example is printing process and DMA
process
A Print Handler Interrupt
Allocating CPU Times
• Is used as a method of allocating CPU time to
different programs that are sharing the CPU
• The computer system provides an internal
clock that sends an interrupt periodically to the
CPU
• Once the CPU receive the interrupt, it will
suspend the current program and go to the next
program to be executed
Time Sharing Interrupt
Abnormal Event Indicator

• Used to handle abnormal events that effect the


operation of the computer
• The events are directly at the problems within
the computer system itself
• An example is execution of an illegal
instructions such as division by zero,
nonexistent code, and hardware error such as
power failure
• Internal interrupts are sometimes called traps
or exceptions

You might also like