Lecture 1_ Computer Architecture
Document Sample


CS 2200 – I/O 1
CS 2200 – Lecture 18
I/O (1)
(Lectures based on the work of Jay
Brockman, Sharon Hu, Randy Katz, Peter
Kogge, Bill Leahy, Ken MacKenzie,
Richard Murphy, and Michael Niemier)
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 2
What is it exactly?
• To anyone in computer science or computer
engineering I/O probably has many different meanings
– My research in computer architecture focuses on
processor design
• So I/O generally just involves a processor/memory
interface
– For a DRAM chip designer, I/O might involve:
• A processor/memory interface
• A memory/disk interface
– For an OS designer, I/O might be:
• An interrupt from a device, input from the user, etc. etc.
• Basically it can mean lots of different things
– In computer architecture levels of memory hierarchy
beyond main memory are often ignored…
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 3
Why study I/O?
• We’ve talked a lot about the CPU time metric
– (In fact I’ve probably stressed it quite a bit!)
• CPU time is important…
– …for measuring how fast an instruction or program is
actually executed…
• But what’s perhaps more important is ―response time‖
– The time between when the user types a command and
when the results appear
• This might be a better measure of performance…
• A brief study of I/O will help complete the picture of
a general computer architecture or organization
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 4
A quick example
• The difference between CPU time and response time
is 10%
– (So, I/O overhead basically adds 10% to our
execution time before user sees results)
• Can speed up CPU by a factor of 10, but I/O
overhead/time will stay the same
– With no changes in the I/O performance, Amdahl’s
law states that:
• We’ll only get a speedup of 5.5! ½ of CPU improvement is
―wasted‖
• What if we make the CPU 100 times faster?
– We’ll only get a speed up of 10! 90% of speedup
wasted!
• With CPU performance skyrocketing, if we don’t
improve I/O, tasks will become ―I/O‖ bound
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 5
Our Road Map
Processor
Memory Hierarchy
I/O Subsystem
Parallel Systems
Networking
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 6
Five Classic Components of a
Computer System
all computers since 1946
Processor
Control
Datapath
Input
Memory Output
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 7
... and the software abstractions
atop them!
operating systems, networking
Processor
Control
Computation:
Processes
Datapath
Threads Input
Communication
I/O devices,
the internet
Storage:
Memory
Virtual Output
Memory,
Files
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 8
I/0 Plan…
• I/O devices in general
– magnetic disks in particular
– networks in particular
• Hardware interface issues
– tradeoff of performance and convenience
– dealing with external events
• Software abstractions
– example: filesystems
– disk head scheduling
– POSIX models all I/O as ―files‖; device drivers
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 9
Roots of I/O Devices
• Telecommunications
– Smoke signals
– Drums
– Optical telegraphy
– Electrical telegraphy
– Wireless telegraphy
– Teletype
– Television
– etc.
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 10
Roots of I/O Devices
• Control/Tabulation
– Jacquard’s Punched Cards
– Hollerith’s tabulating machines
– IBM
• Other technologies
– Magnetic recording
• Wire
• Tape
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 11
Characterization
• Behavior
– Input
– Output
– Storage
Computer
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 12
Characterization
• Partner
– Human
– Machine
Computer
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 13
Characterization
• Data Rate
– Peak rate
Computer
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 14
Types
Device Behavior Partner DataRate kb/s
Keyboard I Human 0.01
Mouse I Human 0.02
Voice Input I Human 0.02
Scanner I Human 400
Voice Output O Human 0.6
Line Printer O Human 1
Laser Printer O Human 200
Graphics Display O Human 60,000
Modem IO Machine 8
Network IO Machine 6,000
Floppy Disk S Machine 100
Optical Disk S Machine 1,000
Magnetic Tape S Machine 2,000
Magnetic Disk S Machine 10,000
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 15
Mouse
I got the idea for the mouse while attending a talk at a computer
conference. The speaker was so boring that I started daydreaming
and hit upon the idea.
Doug Englebart
• Uses mechanical counters or optical devices to generate pulses
which increment or decrement counters
• Counter values determined by polling.
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 16
Magnetic Disks
• ―Drums‖
• Disks
• Removable disk packs
• Floppy disk
– Invented for IBM Field Engineers
– Contact
– Slow speed
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 17
Magnetic Disks
• Most common form of long term, rewriteable storage
devices
• Usually considered the lowest level of memory
hierarchy
• How does a magnetic disk work?
– Collection of platters rotates on a spindle at some RPM
– Platters are metal disks covered with magnetic
recording material on both sides
– Disk diameters can vary
• Usually the wider = faster, ―narrower‖ = cheaper
– Disk surface divided into tracks which are divided into
sectors
– Sectors are the smallest unit that can be written
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 18
A disk, pictorially
• When accessing data we read or write to a sector
– All sectors the same size, outer tracks just less dense
• To read or write, moveable arm with read/write
head moves over each surface
• ―Cylinder‖ = all tracks under the arms at a given
point on all surfaces
• To read or write:
– Disk controller moves arm over proper track – a seek
• The time to move is called the seek time
– When sector found, data is transferred Track Sectors
Tracks
Platters
Platter
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 19
Disk Terminology
Platters
Tracks
Platter
Sectors
Track
Cylinder: Track 'x' on
all platters/surfaces
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 20
The speed of light? No.
• Time required for a requested track sector to rotate
under the read/write head is called the rotation
latency or rotational delay
– Involves mechanical components – on the order of
milliseconds
• i.e. we’re no longer moving at the speed of light like in our
CPU!
• Time required to actually write or read data is called
the transfer time:
– (a function of block size, rotation speed, recording
density on a track, and speed of the electronics
connecting the disk to the computer)
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 21
Disk odds n’ ends
• Often transfer time is a very small portion of a full
access:
– It’s possible to use techniques (discussed in caches) to
help reduce disk overhead. Any thoughts?
• To help reduce complexity there’s usually additional
HW called a ―disk controller‖
– Disk controller helps manage disk accesses…
– …but also adds more overhead – ―controller time‖
• (Can also have a ―queuing delay‖)
– (Time spent waiting for a disk to become free if its
already in use for another access)
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 22
Example – average disk access time
• What is the average time to read or write a 512-
byte sector for a typical disk?
– The average seek time is given to be 9 ms
– The transfer rate is 4 MB per second
– The disk rotates at 7200 RPM
– The controller overhead is 1 ms
– The disk is currently idle before any requests are
made (so there is no queuing delay)
• Average disk access time = average seek time +
average rotational delay + transfer time + controller
overhead
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 23
Capacity trends and disks
• Capacity of disks usually referred to as ―areal
density‖
Tracks Bits
Areal Density on a disk surface on a track
Inch Inch
1000
Cost for 1GB of
magnetic disk space
100
has decreased/
will decrease almost
10 Cost ($)
1
exponentially over
time!
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
0.1
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 24
Magnetic Disks – short overview
• Hard disk
– Higher speed (3600 - 7200+)
– Larger
– Higher Density
– Multiple platters
• Performance
– Seek time (8-20 ms or faster)
– Rotational latency (4-8 ms)
– Transfer rate 2-40 MB/sec
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 25
Disk Latency
Disk Latency = Queuing Time + Controller time +
Seek Time + Rotation Time + Transfer Time
Order of magnitude times for 4K byte transfers:
Seek: 8 ms or less
Rotate: 4.2 ms @ 7200 rpm
Transfer: 1 ms @ 7200 rpm
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 26
Technology Trends
Disk Capacity
now doubles
every
18 months; before
1990 every 36 months
• Today: Processing Power Doubles Every 18 months
The I/O
• Today: Memory Size Doubles Every 18 months(4X/3yr) GAP
• Today: Disk Capacity Doubles Every 18 months
• Disk Positioning Rate (Seek + Rotate) Doubles Every Ten Years!
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 27
Historical Perspective
• 1956 IBM Ramac — early 1970s Winchester
– Developed for mainframes
– Had proprietary interfaces
– Steady shrink in form factor: 27 in. to 14 in.
• 1970s developments
– 5.25 inch floppy disk formfactor (microcode into
mainframe)
– early emergence of industry standard disk interfaces
• ST506, SASI, SMD, ESDI
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 28
Historical Perspective
• Early 1980s
– PCs and first generation workstations
• Mid 1980s
– Client/server computing
– Centralized storage on file server
• accelerates disk downsizing: 8 inch to 5.25 inch
– Mass market disk drives become a reality
• industry standards: SCSI, IPI, IDE
• 5.25 inch drives for standalone PCs, End of proprietary
interfaces
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 29
Disk History
Data
density
Mbit/sq. in.
Capacity of
Unit Shown
Megabytes
1973: 1979:
1. 7 Mbit/sq. in 7. 7 Mbit/sq. in
140 MBytes 2,300 MBytes
source: New York Times, 2/23/98, page C3,
“Makers of disk drives crowd even more data into even smaller spaces”
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 30
Historical Perspective
• Late 1980s/Early 1990s:
– Laptops, notebooks, (palmtops)
– 3.5 inch, 2.5 inch, (1.8 inch formfactors)
– Formfactor plus capacity drives market, not so much
performance
• Recently Bandwidth improving at 40%/ year
– Challenged by DRAM, flash RAM in PCMCIA cards
• still expensive
• unattractive MBytes per cubic inch
– Optical disk fails on performace (e.g., NEXT) but finds
niche (CD ROM)
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 31
Disk History
1989: 1997: 1997:
63 Mbit/sq. in 1450 Mbit/sq. in 3090 Mbit/sq. in
60,000 MBytes 2300 MBytes 8100 MBytes
source: New York Times, 2/23/98, page C3,
“Makers of disk drives crowd even more data into even smaller spaces”
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 32
Something cool…
• This iPod mini…
– A 4 GB disk in a 2‖ x 3.6‖ x 0.5‖ space…
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 33
MBits per square inch:
DRAM as % of Disk over time
9 v. 22 Mb/si
50%
40%
30%
20%
470 v. 3000 Mb/si
10%
0% 0.2 v. 1.7 Mb/si
1974 1980 1986 1992 1998
source: New York Times, 2/23/98, page C3,
“Makers of disk drives crowd even more data into even smaller spaces”
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 34
Technology Trends
Optics
Capacity Speed (latency)
Logic 2x in 3 years 2x in 3 years
DRAM 4x in 3 years 2x in 10 years
Disk 4x in 3 years 2x in 10 years
Aerodynamics Mechanics
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 35
Technology Trends
Optics
Capacity Speed (latency)
Logic 2x in 3 years 2x in 3 years
DRAM 4x in 3 years 2x in 10 years
Disk 4x in 3 years 2x in 10 years
Aerodynamics Mechanics
DRAM-to-Disk density ratio
45%
40%
35%
30%
25%
Disk: 3000Mb/in*in
20%
15%
10% DRAM: 470Mb/in*in
5%
0%
1974 1980 1986 1992 1998
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 36
Magnetic Disks
illustration source unknown
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 37
Second Major Example:
Networks
• Examples:
– System Area Networks (SP2): 100s nodes; ~ 25 meters per link
– Local Area Networks (Ethernet): 100s nodes; ~ 1000 meters
– Wide Area Network (ATM): 1000s nodes; ~ 5,000,000 meters
a.k.a.
end systems,
hosts
a.k.a.
Interconnection Network
network,
communication
subnet
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 38
ABCs of Networks
• Starting Point: Send bits between 2 computers
• Queue (FIFO) on each end
• Information sent called a ―message‖
• Can send both ways (―Full Duplex‖)
• Rules for communication? ―protocol‖
– Inside a computer:
• Loads/Stores: Request (Address) & Response (Data)
• Need Request & Response signaling
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 39
Trivial Example
• What is the format of mesage?
– Fixed? Number bytes?
Request/
Address/Data
Response
1 bit 32 bits
0: Please send data from Address
1: Packet contains data corresponding to request
• Header/Trailer: information to deliver a
message
• Payload: data in message (1 word above)
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 40
Extensions
• What if more than 2 computers want to
communicate?
– Need computer ―address field‖ (destination) in packet
• What if packet is garbled in transit?
– Add ―error detection field‖ in packet (e.g., CRC)
• What if packet is lost?
– More ―elaborate protocols‖ to detect loss
(e.g., NAK, ARQ, time outs)
• What if multiple processes/machine?
– Queue per process to provide protection
• Simple questions such as these lead to elaborate
protocols and packet formats => complexity
– note: complexity often => slow
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 41
A Simple Example Revisted
• What is the format of packet?
– Fixed? Number bytes?
Code Address/Data CRC
2 bits 32 bits 4 bits
00: Request—Please send data from Address
01: Reply—Packet contains data corresponding to request
10: Acknowledge request
11: Acknowledge reply
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 42
Network Media
• There are different ways to connect computers
together…
– Can kind of think of it like a memory hierarchy…
• Different kinds of media vary in cost, performance, and
reliability
• There are several different kinds we’ll consider
– Twisted Pair
– Coaxial Cable
– Fiber Optics
– Air
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 43
Twisted pair media
• Just a twisted pair of copper wires
– Insulated, about 1mm thick
• Twisted together to reduce electrical interference
– Makes sure we don’t turn it into an antenna!
• Data transfer speeds of:
– A few Mbs over a few kilometers; 10s of Mbs over
shorter distances
• Uses:
– Used lots in the telephone industry
– OK for LANs because of reasonable data transfer rates
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 44
Coaxial (coax) cable
• A picture of it is included below
– Consists of copper center surrounded by insulator, a
mesh, and a plastic coating
• Originally developed for cable companies to transmit
at a higher rate over a few kms
• Good bandwidth – 50 ohm coax cable can deliver 10
Mbs over a kilometer
– Good for LAN
Plastic covering
Braided outer conductor
Insulator
Copper core
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 45
Coax cable junctions
• Its harder to connect things to this media however…
• One method is the T-junction
– The typical way this is handled:
• Cable cut in 2 and a connector is inserted that reconnects
the cable and adds a 3rd wire to the computer
– But, if you add a new connector, you have to split the
network and therefore bring it down for a short period
of time
– Additional maintenance is a headache b/c any user can
disconnect the network
• Better – the vampire tap
– Drill a hole to terminate in the copper core
– Screw in connector – no cable cut, no network down
time
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 46
Fiber optics
• Replaces copper with plastic and electrons with
photons
– Information is now transmitted via pulses of light
• Usually, 3 basic components
– Transmission medium – fiber optic cable
– Light source – LED or laser diode
– Light detector – photodiode
• A simplex media – data can only go in 1 direction
• How it works: Total internal
Air reflection
Transmitter Transmitter
-LED -Photodiode
-Laser diode
Silica
Light source
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 47
Fiber optics – how it really works
• Because light is bent/refracted at interfaces, it can
slowly spread out as it travels down the diameter of a
cable…
– Unless that is we transfer a single wavelength of light…
• Then it’ll travel in a straight line
• With this in mind, let’ consider the 2 kinds of fiber
optic cable:
– Multimode Fiber:
• Allows light to be dispersed
• Uses inexpensive LEDs
• Useful for transmissions of about 2 kms; 600 Mbs in 1995
– Single-mode Fiber:
• A single-wavelength fiber
• Uses more expensive laser diodes as light sources
• Transmits Gbs over 100s of kms – great for phone
companies!
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 48
Fiber optics – practical issues
• Single mode fiber is a better transmitter; but more difficult
to attach connectors
– Also, less reliable, more expensive, can’t ―bend‖ as much
– Usually in LAN, multimode is ―the weapon of choice‖
• So, how do you connect fiber optics to a computer?
– Passive Mode:
• Taps are fused into the fiber and a photodiode looks at passing
light
• Electrical output passes to the computer interface
• A failure cuts off just 1 computer
– Active Mode:
• Really a break in the cable
• Light converted to electrical signals, sent to computer, converted
back to light, sent back down cable
• Problem: tap failure causes net failure
• Advantage: light source refreshed, can go longer distances
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 49
Some comparisons
Media Bandwidth Maximum Bandwidth Cost/ Cost for Labor Cost per
Distance * Distance Meter termination cost to computer
install interface
Twisted pair 1Mb/sec 2 km 0.01 $0.23 $4.60 $2.00 ~$2
copper wire (20Mb/sec (0.1 km) Gb-km/sec
)
Coaxial 10 Mb/sec 1 km 0.01 $1.64 $220.00 $15.00 ~$5
cable Gb-km/sec
Multimode 600 2 km 1.20 $1.03 $11.80 $10.00 ~$1000
optical fiber Mb/sec Gb-km/sec
Single-mode 2000 100 km 200.00 $1.64 $23.90 $10.00 ~$1000
optical fiber Mb/sec Gb-km/sec
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 50
The bottom line:
• Bandwidth problems can be fixed with more money for
more wires
• Improving your latency is somewhat more difficult to
do:
– After all, ~299792.5 km/s is kinda fixed
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 51
I/O Device Summary
• Disks/Networks very different but consider these
similarities:
– Data handled in batches (―sectors‖, ―messages‖)
– Lots of waiting around for external events
– Compatibility is important (more than performance)
– Reliability is important (and requires work to achieve)
• Slow devices are simple (and boring)
• Fast devices may be substantially autonomous
– graphics
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 52
I/O: Hardware Interface Issues
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 53
I/O Hardware
• Basic: memory-map w/polling and/or interrupts
– Project 2!
• Advanced: bus issues
– Performance vs. compatibility -> multiple busses
– Namespaces
• Smart device controllers
– Direct Memory Access (DMA)
– Arbitration
– Caching issues
– I/O processors
– the ―wheel of reincarnation‖
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 54
Basic: I/O devices as memory
a la project 2
interrupts
Processor
Cache
Memory - I/O Bus
Main I/O I/O I/O
Memory Controller Controller Controller
Disk Disk Graphics Network
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 55
Performance vs. Compatibility
interrupts
• Problem:
Processor
• Processor -
memory is a
Cache
performance-
crucial path ...
improve as often
Memory - I/O Bus as possible!
Main I/O I/O I/O • I/O controllers
Memory Controller Controller Controller made by many
vendors ...
Graphics change is
Disk Disk Network
expensive!
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 56
Backplane bus
Processor Memory
a. I/O devices
Processor-memory bus
Processor Memory
Bus Bus Bus
adapter adapter adapter
I/O I/O I/O
bus bus bus
b.
Processor-memory bus
Processor Memory
Bus
adapter
Bus I/O bus
adapter
Backplane
bus
Bus I/O bus
Georgia Institute of Technology
adapter
The College of Computing
CS 2200 – I/O 57
Backplane bus
Processor Memory
a. I/O devices
Processor-memory bus
Processor Memory
Bus Bus Bus
adapter adapter adapter
I/O I/O I/O
bus bus bus
b.
Processor-memory bus
Processor Memory
Bus
adapter
Bus I/O bus
adapter
Backplane
bus
Bus I/O bus
adapter
c.
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 58
Multiple Busses
Cache Bus
e.g. 256b, 533MHz
Processor interrupts Memory Bus
Cache
e.g. 64b, 533MHz
Memory Bus I/O Bus
e.g. 64b, 66MHz
bridge
Main
Memory
I/O Bus (e.g. ―PCI‖)
I/O I/O I/O
Disk Drive Bus Controller Controller Controller
e.g. SCSI
16b, 20MHz Disk Disk Graphics Network
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 59
Namespaces
• Two issues:
– Separate namespace for I/O devices or not?
• kind of a historical curiousity at this point
– Assigning the namespace(s) you do have
• physical memory space
• I/O space (if any)
• Interrupt space
• [[[blackboard talk/brainstorming about how to allocate
namespace to devices:
– 1. fixed, i.e. by slot number
– 2. jumpers on the boards (ISA did this)
– 3. software ―jumpers‖ configured at boot time (PCI)
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 60
Smart Device Controllers
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 61
Polling
• Computer • Controller
– Busy bit set? Yes. Busy bit
set? Yes.
– Busy bit set? Yes.
– Busy bit set? Yes.
– Busy bit set? Yes.
– Busy bit set? Yes.
– Busy bit set? Yes.
– Busy bit set? Yes.
– Busy bit set? Yes.
– Busy bit set? Yes.
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 62
Polling
• Computer • Controller
– Controller clears busy bit
– Busy bit set? No.
– Set write bit in command
register
– Write a byte (or word) of
data to Data-out – Sees command ready
– Set command ready bit in – Set busy bit
control register
– Busy bit set? Yes.
– Busy bit set? Yes.
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 63
Polling
• Computer • Controller
– Busy bit set? Yes.
– Busy bit set? Yes. – Checks write bit
– Busy bit set? Yes. – Reads data-out
– Busy bit set? Yes. – Does I/O with device
– Busy bit set? Yes.
– Busy bit set? Yes. – Clears command ready bit
– Busy bit set? Yes. – Clears error bit
– Busy bit set? Yes. – Clears busy bit
– Busy bit set? Yes.
– Busy bit set? No.
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 64
Polling
• Appropriate when controller and device very fast
• Very inefficient when most of the time the controller
is busy
• Better solution...Interrupts
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 65
Interrupts
• Used by I/O controllers to communicate to Processor
• Also used by applications to communicate with
operating system
– Software Interrupt or Trap
• OS can now use same device registers as before
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 66
Interrupts
• Processor • I/O Controller
– Initiate I/O
– Context switch to – Initiate I/O with physical
something else device
– Completion (good or bad)
– Generate interrupt
– Receive interrupt transfer
to handler
– Interrupt handler
processes data, returns
from interrupt
– Resume processing of
interrupted task
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 67
DMA
• Preceding scheme effective but wasteful for large
blocks of data.
• Using sophisticated general-purpose processor for very
specialized function
• Solution: Add enough processing power to device
controller (and possibly bus controller) to allow direct
transfer between device and memory.
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 68
DMA
Processor Memory
Controller
N Processor tells controller
to make DMA transfer.
Assume disk to memory.
Disk (Includes N number of bytes)
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 69
DMA
Processor Memory
Controller
N Controller gets sector of data
from disk.
Disk
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 70
DMA
Processor Memory
Controller
N-1 Controller transfers one word
to memory and updates count.
Disk Checks for termination.
If not...
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 71
DMA
Processor Memory
Controller
N-2 Controller transfers one word
to memory and updates count.
Disk Checks for termination.
If not...
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 72
DMA
Processor Memory
Controller
N-3 Controller transfers one word
to memory and updates count.
Disk Checks for termination.
If not...
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 73
DMA
Processor Memory
Controller
N-4 Controller transfers one word
to memory and updates count.
Disk Checks for termination.
If not...
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 74
DMA
Processor Memory
Controller
N-5 Controller transfers one word
to memory and updates count.
Disk Checks for termination.
If not...
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 75
DMA
Processor Memory
Controller
0 Controller transfers one word
to memory and updates count.
Disk Checks for termination.
If done...
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 76
DMA
Processor Memory
Controller
Controller interrupts processor
Disk
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 77
DMA
Processor Memory
Controller
Processor acknowledges
interrupt
Disk
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 78
DMA
Processor Memory
Controller
Controller sends interrupt vector
Disk
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 79
DMA
Processor Memory
Controller
Processor can now have
scheduler take appropriate
action (i.e. move process
Disk waiting for I/O into ready queue,
etc.)
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 80
Arbitration
• DMA implies multiple ―owners‖ of the bus
– must decide who owns the bus from cycle to cycle
• Arbitration
– Daisy chain
– Centralized parallel arbitration
– Distributed arbitration by self selection
– Distributed arbitration by collision detection
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 81
Daisy Chain
Highest priority Lowest priority
Device 1 Device 2 Device n
Grant Grant
Bus Grant
Release
arbiter
Request
Simple but not fair and slow.
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 82
Centralized Parallel Arbitration
• Requires central arbiter
• Each device has separate line
• Central arbiter may become bottleneck
• Used in PCI bus
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 83
Distributed Arbitration by Self
Selection
• Each device sees all requestors
• Priority scheme allows each to know if they get bus
• Requires lots of request lines
• Used by Apple NuBus (backplane)
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 84
Distributed Arbitration by Collision
Detection
• Devices independently request bus
• Devices have ability to detect simultaneous requests
or Collisions.
• Upon collision a variety of schemes are used to select
among requestors
• Used by Ethernet
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 85
Caching Issues
• What happens if the processor has a cached copy of
data when a device does DMA?
• [[[blackboard talk ... short answer is that there’s a
―cache coherance‖ problem: the DMA may change
memory and the processor doesn’t see the change.
Two solutions
– Device driver (software) flushes cache before using
DMA
– Elaborate bus hardware maintains consistency by
checking the cache on every external bus transaction]]]
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 86
Smart(er) Device Controllers
CPU bridge D1
main memory D2
Mem bus . . .
Dn
I/O
bus
• So far: ―smart‖ meant devices could support DMA
• Note, the bridge could be the unit to support DMA
• Why not add even more functionality than that?
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 87
Input/Output Processors
CPU IOP D1
main memory D2
Mem bus . . .
Dn
I/O target device
bus where cmnds are
CPU issues instruction to IOP OP Device Address
(1) (4)
IOP interrupts when done looks in memory for commands
(2)
(3) memory OP Addr Cnt Other
Device to/from memory what special
transfers are controlled to do requests
by the IOP directly. where how
to put much
IOP steals memory cycles. data
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 88
Input/Output Processors?
CPU IOP D1
main memory D2
Mem bus . . .
Dn
I/O
bus
?
CPU CPU D1
main memory D2
Mem bus . . .
Dn
I/O
bus
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 89
―wheel of reincarnation‖
• Start with simple devices
• Add cute functionality
• Add lots of functionality
• Declare it to be a processor in it’s own right
• Repeat...
• Graphics community has been around this wheel a
couple of times now.
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 90
Summary
• Example Devices
– often work in blocks
– spend lots of time waiting
• Bus Issues
– memory map w/polling and/or interrupts (project 2)
– Performance vs. compatibility -> multiple busses
– Namespaces
• Smart device controllers
– Direct Memory Access (DMA)
– Arbitration
– Caching issues
– I/O processors
– the ―wheel of reincarnation‖
Georgia Institute of Technology The College of Computing
CS 2200 – I/O 91
I/O: Software Abstraction
Next...
Georgia Institute of Technology The College of Computing
Get documents about "