Acessing IO Devices (1)
Acessing IO Devices (1)
ORGANIZATION
Chapter 8
Accessing I/O Devices
Accessing I/O devices
Process Memor
or y
Bu
s
•Multiple I/O devices may be connected to the processor and the memory via a
bus.
•Bus consists of three sets of lines to carry address, data and control signals.
•Each I/O device is assigned an unique address.
•To access an I/O device, the processor places the address on the address lines.
•The device recognizes the address, and responds to the control signals.
Accessing I/O devices (contd..)
⚫ I/O devices and the memory may share the same address
space:
⚫ Memory-mapped I/O.
⚫ Any machine instruction that can access memory can be used to transfer data to
or from an I/O device.
⚫ Simpler software.
4
Accessing I/O devices (contd..)
Address
Bu lines
Data
s lines
Control
lines
Input
device
•I/O device is connected to the bus using an I/O interface circuit which has:
- Address decoder, control circuit, and data and status registers.
•Address decoder decodes the address placed on the address lines thus enabling the
device to recognize its address.
•Data register holds the data being transferred to or from the processor.
•Status register holds information necessary for the operation of the I/O device.
•Data and status registers are connected to the data lines, and have unique
addresses.
•I/O interface circuit coordinates I/O transfers.
Accessing I/O devices (contd..)
⚫ Recall that the rate of transfer to and from I/O devices
is slower than the speed of the processor. This creates
the need for mechanisms to synchronize data transfers
between them.
⚫ Program-controlled I/O:
⚫ Processor repeatedly monitors a status flag to achieve the necessary
synchronization.
⚫ Processor polls the I/O device.
Interrupt
occur i
sher
e i +1
INTA1 INTA p
Priority
arbitration
•Each device has a separate interrupt-request and interrupt-acknowledge line.
•Each interrupt-request line is assigned a different priority level.
•Interrupt requests received over these lines are sent to a priority arbitration
circuit
in the processor.
•If the interrupt request has a higher priority level than the priority of the
processor,
then the request is accepted.
Interrupts (contd..)
⚫ Which interrupt request does the processor accept if it
receives interrupt requests from two or more devices
simultaneously?.
⚫ If the I/O devices are organized in a priority structure,
the processor accepts the interrupt request from a
device with higher priority.
⚫ Each device has its own interrupt request and interrupt acknowledge line.
⚫ A different priority level is assigned to the interrupt request line of each
device.
⚫ However, if the devices share an interrupt request line,
then how does the processor decide which interrupt
request to accept?
Interrupts (contd..)
Polling scheme:
•If the processor uses a polling mechanism to poll the status registers of I/O
devices
to determine which device is requesting an interrupt.
•In this case the priority is determined by the order in which the devices are
polled.
•The firstchain
Daisy device with status bit set to 1 is the device whose interrupt request is
accepted.
scheme: I NTR
Process
or
Devic Devic
INTA1
Process
e e
or
INTR p
Devic Devic
INTA p e e
Priority
circui
arbitration
t
•Devices are organized into groups.
•Each group is assigned a different priority level.
•All the devices within a single group share an interrupt-request line, and
are
connected to form a daisy chain.
Interrupts (contd..)
⚫ Only those devices that are being used in a program should
be allowed to generate interrupt requests.
⚫ To control which devices are allowed to generate interrupt
requests, the interface circuit of each I/O device has an
interrupt-enable bit.
⚫ If the interrupt-enable bit in the device interface is set to 1, then the device is
allowed to generate an interrupt-request.
⚫ Interrupt-enable bit in the device’s interface circuit
determines whether the device is allowed to generate an
interrupt request.
⚫ Interrupt-enable bit in the processor status register or the
priority structure of the interrupts determines whether a
given interrupt will be accepted.
Exceptions
⚫ Interrupts caused by interrupt-requests sent by I/O
devices.
⚫ Interrupts could be used in many other situations where
the execution of one program needs to be suspended and
execution of another program needs to be started.
⚫ In general, the term exception is used to refer to any event
that causes an interruption.
⚫ Interrupt-requests from I/O devices is one type of an exception.
⚫ Trace mode:
⚫ Exception occurs after the execution of every instruction.
⚫ Debugging program is used as the exception-service routine.
⚫ Breakpoints:
⚫ Exception occurs only at specific points selected by the user.
⚫ Debugging program is used as the exception-service routine.
Exceptions (contd..)
⚫ Certain instructions can be executed only when the
processor is in the supervisor mode. These are called
privileged instructions.
⚫ If an attempt is made to execute a privileged
instruction in the user mode, a privilege exception
occurs.
⚫ Privilege exception causes:
⚫ Processor to switch to the supervisor mode,
⚫ Execution of an appropriate exception-servicing routine.
Direct Memory Access
Direct Memory Access (contd..)
⚫ Direct Memory Access (DMA):
⚫ A special control unit may be provided to transfer a block of data directly
between an I/O device and the main memory, without continuous
intervention by the processor.
⚫ Control unit which performs these transfers is a part of
the I/O device’s interface circuit. This control unit is
called as a DMA controller.
⚫ DMA controller performs functions that would be
normally carried out by the processor:
⚫ For each word, it provides the memory address and all the control signals.
⚫ To transfer a block of data, it increments the memory addresses and keeps
track of the number of transfers.
Direct Memory Access (contd..)
⚫ DMA controller can transfer a block of data from an
external device to the processor, without any intervention
from the processor.
⚫ However, the operation of the DMA controller must be under the control of a
program executed by the processor. That is, the processor must initiate the
DMA transfer.
⚫ To initiate the DMA transfer, the processor informs the
DMA controller of:
⚫ Starting address,
⚫ Number of words in the block.
⚫ Direction of transfer (I/O device to the memory, or memory to the I/O device).
⚫ Distributed arbitration:
⚫ All devices participate in the selection of the next bus master.
Centralized Bus Arbitration
B BSY
BR
Processo
r
DMA DMA
controller controller
BG1 1 BG2 2
Centralized Bus Arbitration(cont.,)
● Bus arbiter may be the processor or a separate unit connected to
the bus.
● Normally, the processor is the bus master, unless it grants bus
membership to one of the DMA controllers.
● DMA controller requests the control of the bus by asserting the
Bus Request (BR) line.
● In response, the processor activates the Bus-Grant1 (BG1) line,
indicating that the controller may use the bus when it is free.
● BG1 signal is connected to all DMA controllers in a daisy chain
fashion.
● BBSY signal is 0, it indicates that the bus is busy. When BBSY
becomes 1, the DMA controller which asserted BR can acquire
control of the bus.
Centralized arbitration (contd..)
DMA controller 2
asserts the BR signal. Tim
e
Processor asserts
BR
the BG1 signal
BBSY
Bu
mast
s
Process DMA controller Process
er
or 2 or