Input/Output: The Computer's Response Time Is No Match For Ours
Input/Output: The Computer's Response Time Is No Match For Ours
Memory
Databus
CPU
I/O I/O
Programmed I/O (Polling)
j
& Int A?
Service
routine A
&
Address Int C?
j
Decoder & Service
routine C
Int Z?
j
Service
routine Z
Interrupt
Memory
Databus
CPU
I/O I/O
Interrupt
Interrupt controlled I/O
Data
Int acknowledge
2
Interrupt 1
Interruptroutine
Direct Memory Access
Memory
Databus
CPU
hold
I/O DMA I/O
Direct Memory Access
databus
Hold
CPU Ram
Ack DMA I/O
addressbus
R/W
Evolution in I/O organisation
1. Processor controls device directly
2. A controller or I/O module is used separating the
processor from the details of the I/O device
3. As in 2 but using interrupts, the burden of
supervising the device continuously disappears
4. I/O module gains access to main memory
through DMA moving data in and out memory
without processor attention
5. I/O module becomes a processor - I/O specific
instruction set to be programmed by the
processor in main memory
6. I/O module becomes a computer a channel -
Direct Memory Access
I/O module shares the bus with the processor
It can use the bus only when the CPU does not
need it
Or it can steal cycles from the CPU by forcing it
to free the bus
Procedure:
Processor sends message to DMA (R/W, where, how
much)
Processor continues while I/O proceeds
At the end, I/O module sends interrupt signal to the
processor
Differs from an interrupt
DMA can interrupt the processor in the
middle of an instruction (before fetch, after
decoding, after execution)
It does not interfere with the running
program
The CPU is idled (waiting for access to the
bus)
The system is just becoming slower
Three implementations
DMA shares bus with I/O units
cpu dma
cpu
dma
memory
I/O I/O
bus
Principles: controllers (cont)
Controller-device interface
Very low-level
Example: disk
Preamble with cylinder, sector no,
4096 bits from this sector
Error correction code
Controller produces a block of bytes and performs
error correction if necessary, copies block into
memory
Principles: controllers (cont)
Example: video card
Reads bytes from own memory and generates signals to steer
the CRT
Programming the electron rays is clearly unfeasible for normal
programmers
Controller must offer an abstract interface
Controller-CPU interface
Based on controller registers
These may be part of the normal address space of the
computer (memory mapped I/O) (68x0)
Principles: controllers(cont)
Specific address space for I/O (Intel ports IN and
OUT instructions)
In both cases the decoding logic on the card
recognizes the addresses
They are normally served by system calls
(software interrupts) supporting abstract
commands such as READ, WRITE, SEEK,
FORMAT, RECALIBRATE
CPU passes commands to the controller and
continues. It will be interrupted when the
transaction has finished
Hardware Principles: DMA
Programmed I/O asks for too much attention of the
CPU if the device is fast
Fast devices use Direct Memory Access
Without DMA:
Controller reads block into an internal buffer
Checks for errors, corrects eventually
Causes interrupt
CPU copies block into memory through card registers
Controller starts reading again
7 0 7 0 5 0
6 1 3 4 2 3
54 32 62 51 74 16
Overview
I/O Devices
Principles of I/O Hardware
Design Objecives
Disks
Clocks
Terminals
Design objectives
Efficiency
I/O is very slow in comparison with the CPU
Multiprogramming is partly invented to
circumvent this discrepancy
Even with a high level of multiprogramming,
the I/O cannot cope with the CPU
Swapping is not I/O but it sometimes interferes
with it
Disk efficiency is important
Design objectives
Generic
For simplicity and to avoid errors
Uniform treatment of all devices
Due to the diversity of the devices, only layered
system can offer this uniformity
Layers depend on lower layers for specific
services, implement general set of services
themselves
Number of layers can be different from one
kind of devices to another
Design objectives: three models
User User User
Processes Processes Processes
Directory
Management
File
Logical Comm.
System
I/O Architecture
Physical
Organization
WAN
LAN Dispatcher Tasks
interface
interface
Software: device drivers
One type or at most one class of closely related
devices.
Contains all device dependent code.
E.g. one terminal driver serving all terminals is not
feasible: complexity of terminals can differ too
much.
Is the only part in the OS that knows the
controllers, their register structure, sectors, tracks,
cylinders, heads, interleaving, motors, ...
Device driver translates abstract, device
independent software requests in device dependent
signals.
Software: device drivers (cont)
Example: read a block from disk
If driver is idle when request arrives
Start immediately
Else
Move request to queue
Execute request:
Do a translation to the disk specifics
Find position of the block
Check whether disk is rotating
Check arm position
Pass tasks to device one by one
Some controllers can accept a list of tasks, others need
assistance of the driver after each subtask
Software: device drivers (cont)
Once the task(s) have been passed:
Two possibilities
Driver has to wait until the controller has performed the
task(s), in which case the driver has to block until interrupted
Example: disk I/O, scanner
Or the controller can finish the job without delay
Example: move the graphics over the screen
Current time 3
Clock header
Next signal 4200
3 s1 4 s2 6 s3
Clock Software
Watchdog timers
Floppy disk drive
Start motor
Wait for 500 milliseconds
-> better to wait for 3 seconds after I/O operation,
just in case a new request arrives
Watchdog timers start user specified routine
after the time has elapsed within the code of the
caller
Profiling
For program performance analysis
Information where the CPU time is spent on
Overview
I/O Devices
Principles of I/O Hardware
Design Objecives
Disks
Clocks
Terminals
Terminals, hardware
Serial RS232 terminals
(~history) hardcopy, glass tty, intelligent
Industrial applications
Memory-mapped interfaces
(~history) character oriented
Bitmapped
Network computers
Terminals, hardware (cont)
Serial interfaces: 25 pins connector (RS232
or V24), needed are 3 pins
From 50 up to 19200 bits/sec
Interface: UART (Universal Asynchronous
Receiver Transmitter) on RS232 interface
cards
Driver writes characters to interface card
which transforms them into a bit sequence
Slow, interrupt will wake up the driver
Terminals, hardware (cont)
Interface cards may have a CPU on board,
and be able to serve more terminals
Intelligent terminals may be able to perform
complicated operations on the screen (e.g.
X-terminals) while still connected through a
prehistoric device as the RS UART
Terminals, hardware (cont)
Memory mapped terminals
Integrated into the computer
Communicate through a special memory, the
video RAM, embedded into the address space
of the CPU