Académique Documents
Professionnel Documents
Culture Documents
Processor Memory
I/O Interface
Input Device
I/O Device Speeds
Processors can operate at speeds that are vastly
different than I/O speeds.
When a human is entering characters on a keyboard,
the processor can execute millions of instructions
between successive character entries.
DMA I/O
Polled IO versus Interrupt Driven I/O
Polled IO processor continually checks IO
device to see if it is ready for data transfer
Inefficient, processor wastes time checking for ready
condition
Interrupt Driven IO IO device interrupts
processor when it is ready for data transfer
Processor can be doing other tasks while waiting for
last data transfer to complete very efficient.
I/O Interfacing
A lot of handshaking is required between
the CPU and most I/O devices.
All I/O devices operate asynchronously
with respect to the CPU. The events that
determine when an input device has data
available or when an output device needs
data are independent of the CPU.
Must be capable of data rates fast enough to
keep up with the demands of the device, but
must not be allowed to transfer data faster
than the device can process it.
Polled waiting loops
Interrupt-driven I/O
Direct memory Access (DMA)
Synchronization
The CPU must have some way of checking
the status of the device and waiting until it
is ready to transfer
Transfer Rate
A measure of the number of bytes per
second transferred between the CPU and an
external device.
Maximum transfer rate a measure of the
bandwidth capability of a particular method
of doing I/O.
Comparison of transfer rates
Polled waiting loops provide data rates that are a
bit slower, but still quite reasonable.
Interrupt-driven I/O requires overhead of saving
and restoring the machine state (significantly
degrades data rates unless more than one byte can
be transferred per interrupt.
DMA has fastest transfer rates (additional
hardware complexity needed.
Latency
Measure of the delay from the instant that
the device is ready until the time the first
data byte is transferred. Latency is
equivalent to the response time
Comparison of Latency
Polled Waiting Loops latency can be very
high (the computer may not even be
checking the device for new data when it
arrives).
Interrupt-driven I/O dramatically lower
than polled, but still imposes a software
overhead.
DMA very low (lower than the others)
Polled Waiting I/O
Use software to test the status of a
device,before transferring each data byte.
Continuously checking the peripherals
BUSY/READY flag
Ties up the CPU no other tasks can be
performed.
I/O Systems
interrupts
Processor
Cache
CPU
common memory
& I/O bus
Peripheral Peripheral
Example of an Interface
Interface to system bus
data registers
control/status registers
I/O logic used for decoding commands from the processor such as
read, write, scan, address recognition, status reporting etc.
External device interface (data, status, control)
function of the interface:
control and timing
processor communication
device communication
data buffering
error correction
Next how does the CPU address an I/O device to send or receive data?
Memory Mapped I/O
CPU
Single Memory & I/O Bus
No Separate I/O Instructions
ROM
Peripheral Peripheral
I/O
In this mode, there is a single address space for memory locations and
I/O devices. Each I/O device will have unique addresses for its data and
status registers which are treated just like any other memory location.
The bus will contain data and address lines and some I/O command lines
The command line specifies whether the address refers to a memory
location or an I/O device.
The alternative solution is isolated I/O address space and I/O opcodes.
In this case I/O ports are only accessible by special I/O instructions.
Programmed I/O (Polling)
1. The CPU
CPU periodically
checks status
bits to see if
there is I/O
Memory IOC operation.
(3) interrupt
device service addr
read
store interrupt
... service
User program progress only halted during (4) rti routine
actual transfer memory
to deal with different I/O devices, interrupt
mechanisms have several levels of priority. These
priorities indicate the order in which the processor
should process the interrupts.
Direct Memory Access Controllers
CPU
device
main memory D2
Mem bus . . .
Dn
I/O
bus
CPU
(1) (4) issues instruction to IOP
IOP interrupts when done
(2)
(3) memory
other
Memory devices
I/O device I/O device
Interrupt
Databus controller
Address bus
Direct Memory
CPU Access (DMA)
IRQ FIQ Controller
other devices
Method 1: Polling
CPU repeatedly reads status bit from serial port (bit 31 of
PORT_STATUS here) to determine if new data is available
When needed it reads data from PORT_DATA(7:0)
Polling is simple, requires no additional hardware
Requires 100% CPU use, inefficient, inflexible
IO_SERVICE_CODE
ADRL R10, SER_PORT ; R10--> SERIAL_PORT
ADR R11, BUFFER ; R11-> array of bytes read
POLL_LOOP ; example of polling I/O
LDR R0, [R10,#PORT_STATUS];input status
CMP R0, #0
BPL POLL_LOOP ; wait till port is ready b31=1
LDRB R0, [R10,#PORT_DATA] ; input data
STRB R0, [R11], #1 ; store data in memory
B POLL_LOOP ; repeat
Method 2: Interrupt
other
Memory devices
I/O device I/O device
Interrupt
Databus controller
Address bus
Mode bits
Shadow Registers Clever Feature of ARM
ISA enables Exceptions
As the processor enters an exception mode, some new registers are
automatically switched in to avoid overwriting user regs:-
Interrupt
Databus controller
Address bus
Direct Memory
CPU Access (DMA)
IRQ FIQ Controller
other devices
Direct Memory Access (contd)
DMA
Polling Interrupt