Chapter 5 of Arch
Chapter 5 of Arch
Input/output Organization
Objectives:
By the end of this chapter, you should be able to:
Discuss the classification of external devices
Discuss I/O problems and functions of I/O modules
Explain the concept of programmed I/O.
Explain the various I/O instructions
Explain the concept of Interrupt driven I/O.
Explain the DMA function, operation and configurations
1
called Interface is often referred to as a peripheral device or simply a
peripheral.
Keyboard
and display Magnetic Magnetic
Printer
terminal disk tape
2
Input/output Problems
The major functions or requirements for an I/O module fall into the
following five categories.
Control & Timing
CPU Communication
Device Communication
Data Buffering
Error Detection
During any period of time, the CPU may communicate with one or more
external devices in unpredictable patterns on the program’s need for I/O.
The internal resources, main memory and the CPU must be shared
3
among number of activities including handling data I/O. Thus the I/O
device includes a control and timing requirement to coordinate the flow
of traffic between internal resources and external devices to the CPU.
Thus CPU might involve in sequence of operations like:
CPU checks I/O module device status
4
The I/O module must also be able to perform device communication.
This communication involves commands, status information, and data.
Some of the essentials tasks are listed below:
Error detection: I/O module is often responsible for error
Three techniques are possible for I/O operations or data transfer mode.
They are:
Programmed I/O
Interrupt driven
Direct Memory Access (DMA)
With Programmed I/O, data are exchanged between the CPU and the
I/O module. The CPU executes a program that gives it direct control of
the I/O operation, including sensing device status, sending a read or
write command and transferring data. When CPU issues a command to
5
I/O module, it must wait until I/O operation is complete. If the CPU is
faster than I/O module, there is wastage of CPU time.
The I/O module does not take any further action to alert CPU. That is it
doesn’t interrupt CPU. Hence it is the responsibility of the CPU to
periodically check the status of the I/O module until it finds that the
operation is complete.
The sequences of actions that take place with programmed I/O are:
CPU requests I/O operation
I/O commands
I/O Mapping
When the CPU, main memory, and I/O module share a common bus two
modes of addressing are possible.
2. Isolated I/O
Separate address spaces
Need I/O or memory select lines
Special commands for I/O
Limited set
7
7.3.2 Interrupt Driven I/O
With Interrupt driven I/O, the CPU issues a command to I/O module
and it does not wait until I/O operation is complete but instead continues
to execute other instructions. When I/O module has completed its work
it interrupts the CPU.
Using Interrupt Driven I/O technique CPU issues read command. I/O
module gets data from peripheral while CPU does other work and I/O
8
module interrupts CPU checks the status if no error that is the device is
ready then CPU requests data and I/O module transfers data. Thus CPU
reads the data and stores it in the main memory.
When the CPU detects an interrupt, it then saves its current state (at least
the PC and the Processor Status Register containing condition codes);
this state information is usually saved in memory. After the interrupt has
been serviced, this state information is restored in the CPU and the
9
previously executing software resumes execution as if nothing had
happened.
10
Figure 7-3: Input block of data using DMA access
Device address
Starting address of memory block for data
Amount of data to be transferred
The CPU carries on with other work.
Thus DMA controller steals the CPU’s work of I/O operation.
The DMA module transfers the entire block of data,
One word at a time, directly to or from memory, without going
through CPU.
When the transfer is complete
DMA controller sends interrupt when finished
11
Thus CPU is involved only at the beginning and at the end of the
transfer.
DMA Configurations
In this configuration all modules share the same system bus. The block
diagram of single bus detached DMA is as shown in Figure 7-4. The
DMA module that is mimicking the CPU uses the programmed I/O to
exchange the data between the memory and the I/O module through the
DMA module. This scheme may be inexpensive but is clearly
inefficient. The features of this configuration are:
Single Bus, Detached DMA controller
12
Here, there is a path between DMA module and one or more I/O
modules that do not include the system bus. The block diagram of single
bus Integrated DMA is as shown in Figure 7-5. The DMA logic can
actually be considered as a part of an I/O module or there may be a
separate module that controls one more I/O modules.
Figure 7-5: Block diagram of single bus, integrated DMA
13
DMA using I/O bus is as shown in Figure 7-6. Here the system bus that
the DMA shares with CPU and main memory is used by DMA module
only to exchange data with memory. And the exchange of data between
the DMA module and the I/O modules takes place off the system bus
that is through the I/O bus.
Figure 7-6: Diagram of DMA using I/O bus
System bus
DMA Main
CPU Controller Memory
I/O bus
I/O I/O I/O I/O
device device device device
With both Programmed I/O and Interrupt driven I/O the CPU is
responsible for extracting data from main memory for output and storing
data in main memory for input. Table 7-1 indicates the relationship
among the three techniques.
Advantages of DMA
DMA has several advantages over polling and interrupts. DMA is fast
because a dedicated piece of hardware transfers data from one computer
location to another and only one or two bus read/write cycles are
required per piece of data transferred. In addition, DMA is usually
required to achieve maximum data transfer speed, and thus is useful for
high speed data acquisition devices. DMA also minimizes latency in
servicing a data acquisition device because the dedicated hardware
responds more quickly than interrupts and transfer time is short.
Minimizing latency reduces the amount of temporary storage (memory)
required on an I/O device. DMA also off-loads the processor, which
means the processor does not have to execute any instructions to transfer
data. Therefore, the processor is not used for handling the data transfer
activity and is available for other processing activity. Also, in systems
where the processor primarily operates out of its cache, data transfer is
actually occurring in parallel, thus increasing overall system utilization.
15