Download - Input output systems
-
7/21/2019 Input output systems
1/31
Silberschatz, Galvin a nd Gagne 200213.1
Chapter 13: I/O Systems
I/O HardwareApplication I/O InterfaceKernel I/O SubsystemTransforming I/O Requests to Hardware O perationsStreamsPerformance
-
7/21/2019 Input output systems
2/31
Silberschatz, Galvin a nd Gagne 200213.2
I/O Hardware
Incredible variety of I/O devicesCommon concepts
PortBus ( daisy chain or shared direct access)Controller (host adapter)
I/O instructions control devicesDevices h ave a ddresses, used by
Direct I/O instructionsMemory-mapped I/O
-
7/21/2019 Input output systems
3/31
Silberschatz, Galvin a nd Gagne 200213.3
A Typical PC Bus Structure
-
7/21/2019 Input output systems
4/31
Silberschatz, Galvin a nd Gagne 200213.4
Device I/O Port Locations on PCs (partial)
-
7/21/2019 Input output systems
5/31
Silberschatz, Galvin a nd Gagne 200213.5
Polling
Determines state of device command-ready busy
Error
Busy-wait cycle to wait for I/O from device
-
7/21/2019 Input output systems
6/31
Silberschatz, Galvin a nd Gagne 200213.6
Interrupts
CPU Interrupt request line triggered by I/O device
Interrupt handler receives interrupts
Maskable to ignore or delay s ome interrupts
Interrupt vector to dispatch interrupt to correct handlerBased on prioritySome unmaskable
Interrupt mechanism also used for exceptions
-
7/21/2019 Input output systems
7/31Silberschatz, Galvin a nd Gagne 200213.7
Interrupt-Driven I/O Cycle
-
7/21/2019 Input output systems
8/31Silberschatz, Galvin a nd Gagne 200213.8
Intel Pentium Processor Event-Vector Table
-
7/21/2019 Input output systems
9/31Silberschatz, Galvin a nd Gagne 200213.9
Direct Memory Access
Used to avoid programmed I/O for large data movement
Requires D MA controller
Bypasses C PU to transfer data directly b etween I/O
device and memory
-
7/21/2019 Input output systems
10/31Silberschatz, Galvin a nd Gagne 200213.10
Six Step Process to Perform DMA Transfer
-
7/21/2019 Input output systems
11/31Silberschatz, Galvin a nd Gagne 200213.11
Application I/O Interface
I/O system calls e ncapsulate device behaviors i n genericclassesDevice-driver layer hides d ifferences a mong I/Ocontrollers from kernelDevices vary in many d imensions
Character-stream or blockSequential or random-accessSharable or dedicatedSpeed of operationread-write, read only, or write only
-
7/21/2019 Input output systems
12/31Silberschatz, Galvin a nd Gagne 200213.12
A Kernel I/O Structure
-
7/21/2019 Input output systems
13/31Silberschatz, Galvin a nd Gagne 200213.13
Characteristics of I/O Devices
-
7/21/2019 Input output systems
14/31Silberschatz, Galvin a nd Gagne 200213.14
Block and Character Devices
Block devices i nclude disk drives Commands include read, write, seekRaw I/O or le-system accessMemory-mapped le a ccess possible
Character devices i nclude keyboards, mice, serial ports Commands include get, putLibraries layered on top allow line editing
-
7/21/2019 Input output systems
15/31Silberschatz, Galvin a nd Gagne 200213.15
Network Devices
Varying enough from block a nd character to have owninterface
Unix and W indows NT/9 i /2000 include socket interfaceSeparates n etwork p rotocol from network o peration
Includes select functionality
Approaches va ry widely (pipes, FIFOs, streams, queues,mailboxes)
-
7/21/2019 Input output systems
16/31
Silberschatz, Galvin a nd Gagne 200213.16
Clocks and Timers
Provide current time, elapsed time, timer
If programmable interval time used for timings, periodicinterrupts
ioctl (on UNIX) covers o dd aspects o f I/O such asclocks and timers
-
7/21/2019 Input output systems
17/31
Silberschatz, Galvin a nd Gagne 200213.17
Blocking and Nonblocking I/O
Blocking - process s uspended until I/O completed Easy t o use and understandInsufficient for some needs
Nonblocking - I/O call returns as much as available
User interface, data copy (buffered I/O)Implemented via multi-threadingReturns q uickly w ith count of bytes r ead or written
Asynchronous - process r uns w hile I/O executes
Difficult to useI/O subsystem signals p rocess w hen I/O completed
-
7/21/2019 Input output systems
18/31
Silberschatz, Galvin a nd Gagne 200213.18
Kernel I/O Subsystem
SchedulingSome I/O request ordering via per-device queueSome O Ss try fairness
Buffering - store data in memory w hile transferring
between devices To cope with device sp eed mismatchTo cope with device transfer size mismatchTo maintain copy s emantics
-
7/21/2019 Input output systems
19/31
Silberschatz, Galvin a nd Gagne 200213.19
Sun Enterprise 6000 Device-Transfer Rates
-
7/21/2019 Input output systems
20/31
Silberschatz, Galvin a nd Gagne 200213.20
Kernel I/O Subsystem
Caching - fast memory holding copy of dataAlways just a copyKey t o performance
Spooling - hold output for a device
If device can serve only o ne request at a timei.e., Printing
Device reservation - provides exclusive access to adevice
System calls for allocation and deallocationWatch out for deadlock
-
7/21/2019 Input output systems
21/31
Silberschatz, Galvin a nd Gagne 200213.21
Error Handling
OS can recover from disk read, device unavailable,transient write failures
Most return an error number or code when I/O requestfails
System error logs h old problem reports
-
7/21/2019 Input output systems
22/31
Silberschatz, Galvin a nd Gagne 200213.22
Kernel Data Structures
Kernel keeps s tate info for I/O components, includingopen le tables, network c onnections, character devicestate
Many, many co mplex data structures t o track b uffers,memory allocation, dirty blocks
Some u se o bject-oriented methods a nd message passingto implement I/O
-
7/21/2019 Input output systems
23/31
Silberschatz, Galvin a nd Gagne 200213.23
UNIX I/O Kernel Structure
-
7/21/2019 Input output systems
24/31
Silberschatz, Galvin a nd Gagne 200213.24
I/O Requests to Hardware Operations
Consider reading a le from disk for a process:
Determine device holding leTranslate name to device representationPhysically r ead data from disk into buffer
Make data available to requesting processReturn control to process
-
7/21/2019 Input output systems
25/31
Silberschatz, Galvin a nd Gagne 200213.25
Life Cycle of An I/O Request
-
7/21/2019 Input output systems
26/31
Silberschatz, Galvin a nd Gagne 200213.26
STREAMS
STREAM a full-duplex communication channel betweena user-level process and a device
A STREAM consists of:- STREAM head interfaces with the user process
- driver end interfaces with the device- zero or more STREAM modules between them.
Each module co ntains a read queue and a write q ueue
Message passing is used to communicate betweenqueues
-
7/21/2019 Input output systems
27/31
Silberschatz, Galvin a nd Gagne 200213.27
The STREAMS Structure
-
7/21/2019 Input output systems
28/31
Silberschatz, Galvin a nd Gagne 200213.28
Performance
I/O a major factor in system performance:
Demands C PU to execute device driver, kernel I/O codeContext switches due to interruptsData copying
Network traffic e specially st ressful
-
7/21/2019 Input output systems
29/31
Silberschatz, Galvin a nd Gagne 200213.29
Intercomputer Communications
-
7/21/2019 Input output systems
30/31
Silberschatz, Galvin a nd Gagne 200213.30
Improving Performance
Reduce number of context switchesReduce data co pyingReduce interrupts b y u sing large transfers, smartcontrollers, pollingUse DMA
Balance C PU, memory, bus, and I/O performance forhighest throughput
-
7/21/2019 Input output systems
31/31
Device-Functionality Progression