CSCE 351 Operating System Kernels: Steve Goddard
CSCE 351 Operating System Kernels: Steve Goddard
Steve Goddard
[email protected]
http://www.cse.unl.edu/~goddard/Courses/CSCE351
I/O Hardware
x
I/O Devices
Block Devices Character Devices
Device Controllers
Memory-mapped I/O I/O Ports Interrupt Request Line (IRQ)
x x
I/O Devices
x
Block Devices
Information is stored and accessed in fixed-size blocks Block addressable, not byte addressable Common block sizes: 512 32,768 bytes Examples?
Character Devices
Send or receive streams of characters NOT byte or block addressable Examples?
What about
Tape drives? Clocks? Memory-mapped screens? Mice?
3
Device Controllers
x x
x x
Most I/O devices are electro-mechanical. The electrical component that interfaces with the CPU (actually the OS) is called the device controller or adapter. The Controller is the go-between for the OS and the device Controllers for PCs and embedded devices are implemented as daughter cards and inserted into the backplane of the parentboard (or motherboard)
Memory-mapped I/O
Controller Registers are part of regular address space Usually flags in special registers indicate that the memory access is for memory-mapped I/O Used by Motorola 680x0 processors
x x
I/O Ports
Each controller is assigned a special address called a port.
Anatomy of a Disk
Basic components
Track s1 0 1 2
...
Surface Spindle
Platter
Anatomy of a Disk
Example: Seagate 9GB Fast/Wide/Differential SCSI disk
x
Seek times
y y
Disk Operations
Data transfer in units of sectors Random access devices with non-uniform access times
x x x x
The appropriate head is enabled Wait for the sector to appear under the head
rotational latency
10
Disk Interleaving
x
Blocks are often placed on the disk in nonsequential order to allow time for the DMA buffer to be transferred to main memory.
No interleaving
Single interleaving
Double interleaving
11
I/O Software
x x
12
Device independence
Read and Write from Floppy, Disk, CD-ROM without modifying programs Names are not dependent on the specific device
y
Uniform naming
Different devices of same type have similar name
In UNIX, all I/O is integrated with the file system Propagate errors up only when lower layer cannot handle it. Hide errors as much as possiblemany HW errors are transient Most I/O hardware operates asynchronously Synchronous (blocking) read/write easier to program
13
Structured I/O SW to meet these Goals User-level Software Device-Independent OS SW Device Drivers Interrupt Handlers
14
Interrupt Handlers
x x
Hidden from applications Used to bridge gap between asynchronous I/O hardware and synchronous read/write semantics Often implemented as top-half and bottom-half handlers
Top-half
y y
does as little as possible not scheduled closely related to (if not exactly) the device driver scheduled
Bottom-half
y y
15
Device Drivers
x x x
Device dependent code Each device driver handles (at most) one class of devices Device drivers communicate with the device controllers
Only part that knows the details of the device. Hence, device dependent
16
Device Driver
Block to Sector Mappings
Surface
?
Sector
Track
Device driver translates block requests into cylinder, track, and sector requests.
t1 ... p1 ... 1 0
1 0
...
s1 0 1
17
Device protection Providing a device-independent block size Buffering Storage allocation on block devices Allocation and releasing dedicated devices Error Reporting
User-Space I/O SW
x
I/O Libraries (e.g., stdio) are in user-space to provide an interface to the OS resident device-independent I/O SW
These routines do the formatting for the user that is such a pain to do, but everyone wants it
19
20