Chapter 4 PDF
Chapter 4 PDF
CHAPTER 4
Input Output Systems
attached.
Thus, an I/O module is required.
When the processor issues an I/O command, the command contains the address of the device that
is used by the command. The I/O module must interpret the address lines to check if the command
is for itself.
Generally in most of the processors, the processor, main memory and I/O share a common bus
(data address and control bus). Two types of addressing are possible:
Memory-mapped I/O
Isolated or I/O mapped I/O
Memory-mapped I/O: There is a single address space for memory locations and I/O devices. The
processor treats the status and address register of the I/O modules as memory location. For
example, if the size of address bus of a processor is 16, then there are 216 combinations and all
together 216 address locations can be addressed with these 16 address lines.
Out of these 216 address locations, some address locations can be used to address I/O devices and
other locations are used to address memory locations. Since I/O devices are included in the same
memory address space, so the status and address registers of I/O modules are treated as memory
location by the processor. Therefore, the same machine instructions are used to access both
memory and I/O devices.
Isolated or I/O -mapped I/O: In this scheme, the full range of addresses may be available for both.
The address refers to a memory location or an I/O device is specified with the help of a command
line. In general IO/M command line is used to identify a memory location or an I/O device.
if IO/M = 1, it indicates that the address present in address bus is the address of an I/O device.
if IO/M = 0, it indicates that the address present in address bus is the address of a memory location.
Since full range of address is available for both memory and I/O devices, so, with 16 address lines,
the system may now support both 216 memory locations and 216 I/O addresses.
For input, the I/O module services a READ command from the processor.
The I/O module then proceeds to read data from an associated peripheral device.
Once the data are in the modules data register, the module issues an interrupt to the
processor over a control line.
The module then waits until its data are requested by the processor.
When the request is made, the module places its data on the data bus and is then ready for
another I/O operation.
B. From the processor point of view; the action for an input is as follows:
The processor issues a READ command.
It then does something else (e.g. the processor may be
working on several different programs at the same time)
At the end of each instruction cycle, the processor
checks for interrupts
When the interrupt from an I/O module occurs, the
processor saves the context (e.g. program counter &
processor registers) of the current program and
processes the interrupt.
In this case, the processor reads the word of data from
the I/O module and stores it in memory.
It then restores the context of the program it was working
on and resumes execution.
Following figure shows the use of interrupt I/O for reading in a
block of data. Interrupt I/O is more efficient than programmed
I/O because it eliminates needless waiting. However, interrupt
I/O still consumes a lot of processor time, because every word
of data that goes from memory to I/O module or from I/O module
Fig: Interrupt I/O
to memory must pass through the processor.
contents of program counter. These can be pushed into the system control stack.
5. The processor now loads the program counter with the entry location of the interrupt handling
program that will respond to the interrupt.
Once the program counter has been loaded, the processor proceeds to the next instruction cycle,
which begins with an interrupt fetch. The control will transfer to interrupt handler routine for the
current interrupt. The following operations are performed at this point.
6. At the point, the program counter and PSW relating to the interrupted program have been saved
on the system stack. In addition to that some more information must be saved related to the current
processor state which includes the control of the processor registers, because these registers may
be used by the interrupt handler. Typically, the interrupt handler will begin by saving the contents of
all registers on stack.
7. The interrupt handles next processes the interrupt. This includes an examination of status
information relating to the I/O operation or, other event that caused an interrupt.
8. When interrupt processing is complete, the saved register values are retrieved from the stack and
restored to the registers.
9. The final act is to restore the PSW and program counter values from the stack. As a result, the
next instruction to be executed will be from the previously interrupted program.
the active intervention of the processor to transfer data between memory and the I/O module, and
any data transfer must transverse a path through the processor. Thus both these forms of I/O suffer
from two inherent drawbacks.
The I/O transfer rate is limited by the speed with which the processor can test and service a
device.
The processor is tied up in managing an I/O transfer; a number of instructions must be
executed for each I/O transfer.
To transfer large block of data at high speed, a special control unit may be provided to allow transfer
of a block of data directly between an external device and the main memory, without continuous
intervention by the processor. This approach is called direct memory access or DMA.
DMA transfers are performed by a control circuit associated with the I/O device and this circuit is
referred as DMA controller. The DMA controller allows direct data transfer between the device and
the main memory without involving the processor.
When the processor wishes to read or write a block of data, it issues a command to the DMA module,
by sending to the DMA module the following information.
Whether a read or write is requested, using the read or write control line between the
processor and the DMA module.
The address of the I/O devise involved, communicated on the data lines.
The starting location in the memory to read from or write to, communicated on data lines and
stored by the DMA module in its address register.
The number of words to be read or written again communicated via the data lines and stored
in the data count register.
The processor then continues with other works. It has delegated this I/O operation to the DMA
module. The DMA module checks the status of the I/O devise whose address is communicated to
DMA controller by the processor. If the specified I/O devise is ready for data transfer, then DMA
module generates the DMA request to the processor. Then the processor indicates the release of
the system bus through DMA acknowledge. The DMA module transfers the entire block of data, one
word at a time, directly to or from memory, without going through the processor.
When the transfer is completed, the DMA module sends an interrupt signal to the processor. After
receiving the interrupt signal, processor takes over the system bus. Thus the processor is involved
only at the beginning and end of the transfer. During that time the processor is suspended.
It is not required to complete the current instruction to suspend the processor. The processor may
be suspended just after the completion of the current bus cycle. On the other hand, the processor
can be suspended just before the need of the system bus by the processor, because DMA controller
is going to use the system bus, it will not use the processor. The point where in the instruction cycle
the processor may be suspended shown in the figure.