Operating Systems Lecture Notes
15 February 2012 • Peripheral Devices
Outline
The Problem
What are these things hanging off the system?
And why are they there?
How does the operating system deal with them?
Peripheral Devices
Peripheral devices
(or
peripherals
or
devices
) are information handlers.
A device may be an information
source
(keyboard), or
a
sink
(display),
a source and a sink (disks).
A device may store information (tapes), or transmits it (networks).
Devices Differences
Devices differ drastically in their characteristics.
Differ from each other, and from the host system.
The differences include
Qualitative: input only (mouse), output only (audio), or input-output (disk).
Quantitative: transfer rates, capacity, reliability.
Ephemeral (networks) or not (printers).
Devices In A System
Management Objectives
Devices should be managed to provide:
Protection - devices are shared objects; they handle unshared information.
Convenience - devices are gnarly, varied, and always changing.
Efficiency - devices are bottle-necks; they are abstract.
The central conflict - abstraction vs. control; convenience vs. efficiency
Device Management
Provide efficient data transfer between device and system.
I-O system organization - the device driver, the resource manager.
Provide interfaces - application, kernel, and device.
Operate the device.
Keep track of pending requests.
Enforce the resource policy.
Device Operation
Establish data and parameters; start the operation; wait for completion; determine status; handle results; repeat
Which does what?
CPU vs. device.
The trend is to move function from the CPU to the device.
CPU-Device Interaction
The CPU directs the device, and possibly helps with some functions - error recovery.
Several styles of CPU-device interaction.
Polling
Interrupts
Direct memory access.
Channel processors.
Device Polling
CPU continually tests for completion.
Doesn’t scale well, difficult to get right, wastes the CPU.
Device Interrupts
Interrupt-driver driven I-O - efficiently waiting for completion.
The device informs the CPU when completed.
Scales well, relatively easy to program, efficient CPU use.
Direct Memory Access
Direct memory access
(
DMA
) moves data between the device and system.
Devices may have buffers to store data.
The CPU can do it - expensive.
The device can do it - needs access to memory; capable devices.
Memory-Mapped I-O
How do the CPU and devices communicate?
Special cpu instructions.
Writing locations memory - memory-mapped I-O.
Buffering
Amortize operations over more data -
n
1-byte operations vs 1
n
-byte operation.
Smooth out bursty data transmissions.
Even out the speed disparity - double buffering.
Summary
References
This page last modified on 2012 February 15.