Io
Io
Io
Input/Output Devices
(Ch 13: 13.1-13.5)
(Ch 12: 12.1-12.4)
Introduction
One OS function is to control devices
significant fraction of code (80-90% of Linux)
Outline
Introduction
Hardware
Software
Specific Devices
Hard disk drives
Clocks
(done)
Hardware
Device controllers
Types of I/O devices
Direct Memory Access (DMA)
Device Controllers
Mechanical and electronic component
The quick brown
fox jumped over
the lazy dogs. The
quick brown fox...
Mechanical
Electronic
CPU
Memory
System bus
Disk
Controller
Printer
Controller
other
ex- clocks (just generate interrupts)
Very Old
Old
DMA
Outline
Introduction
Hardware
Software
Specific Devices
Hard disk drives
Clocks
(done)
(done)
Interrupt Handlers
Hardware
Interrupt Handlers
CPU
1) Device driver initiates
I/O
(CPU executing,
checking for interrupts
between instructions)
3) Receives interrupt,
transfer to handler
4) Handler processes
(Resume processing)
I/O Controller
1) Initiates I/O
(I/O device processing
request)
2) I/O complete.
Generate interrupt.
Interrupt Handler
Make interrupt handler as small as possible
interrupts disabled
Split into two pieces
Device Drivers
Device dependent code
includes interrupt handler
Spooling
spool directory, daemon
ex: printing, USENET
I/O Reply
I/O Request
Device Independent
Software
Device Drivers
Interrupt Handlers
Hardware
Outline
Introduction
Hardware
Software
Specific Devices
Hard disk drives
Clocks
(done)
(done)
(done)
often on disk
Cache to
speed access
HDD - Zoom
Platters
+
3000-10,000 RPM
x x
9 10
11 12 13 14 15 16
17 18 19 20
Time
14+13+2+6+3+12+3=53
Service requests in order that they arrive
Little can be done to optimize
What if many requests?
x x
9 10
11 12 13 14 15 16
Time
1+2+6+9+3+2 = 23
Suppose many requests?
Stay in middle
Starvation!
17 18 19 20
Elevator (SCAN)
1
Time
x x
9 10
11 12 13 14 15 16
17 18 19 20
1+2+6+3+2+17 = 31
Usually, a little worse avg seek time than SSF
But avoids more fair, avoids starvation
For speed
Pull data in parallel
For fault-tolerance
Example: 38 disks, form 32 bit word, 6 check bits
Example: 2 disks, have exact copy on one disk
Error Handling
Common errors:
Clock Hardware
Time of day to time quantum
Pulse from 5 to 300 MHz
Crystal Oscillator
Decrement counter
when == 0
- generate interrupt
Holding register to
load counter
Can control clock ticks