Chapter 13 - I/O Systems

WayneJonesJnr 15,457 views 38 slides Apr 20, 2009
Slide 1
Slide 1 of 38
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38

About This Presentation

I/O Hardware
Application I/O Interface
Kernel I/O Subsystem
Transforming I/O Requests to Hardware Operations
Streams
Performance


Slide Content

Chapter 13: I/O SystemsChapter 13: I/O Systems

13.2 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Chapter 13: I/O SystemsChapter 13: I/O Systems
nI/O Hardware
nApplication I/O Interface
nKernel I/O Subsystem
nTransforming I/O Requests to Hardware Operations
nStreams
nPerformance

13.3 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
ObjectivesObjectives
nExplore the structure of an operating system’s I/O subsystem
nDiscuss the principles of I/O hardware and its complexity
nProvide details of the performance aspects of I/O hardware and
software

13.4 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
I/O HardwareI/O Hardware
nIncredible variety of I/O devices
nCommon concepts
lPort
lBus (daisy chain or shared direct access)
lController (host adapter)
nI/O instructions control devices
nDevices have addresses, used by
lDirect I/O instructions
lMemory-mapped I/O

13.5 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
A Typical PC Bus StructureA Typical PC Bus Structure

13.6 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Device I/O Port Locations on PCs (partial)Device I/O Port Locations on PCs (partial)

13.7 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
PollingPolling
nDetermines state of device
lcommand-ready
lbusy
lError
nBusy-wait cycle to wait for I/O from device

13.8 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
InterruptsInterrupts
nCPU Interrupt-request line triggered by I/O device
nInterrupt handler receives interrupts
nMaskable to ignore or delay some interrupts
nInterrupt vector to dispatch interrupt to correct handler
lBased on priority
lSome nonmaskable
nInterrupt mechanism also used for exceptions

13.9 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Interrupt-Driven I/O CycleInterrupt-Driven I/O Cycle

13.10 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Intel Pentium Processor Event-Vector Intel Pentium Processor Event-Vector
TableTable

13.11 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Direct Memory AccessDirect Memory Access
nUsed to avoid programmed I/O for large data movement
nRequires DMA controller
nBypasses CPU to transfer data directly between I/O device and memory

13.12 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Six Step Process to Perform DMA Six Step Process to Perform DMA
TransferTransfer

13.13 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Application I/O InterfaceApplication I/O Interface
nI/O system calls encapsulate device behaviors in generic classes
nDevice-driver layer hides differences among I/O controllers from
kernel
nDevices vary in many dimensions
lCharacter-stream or block
lSequential or random-access
lSharable or dedicated
lSpeed of operation
lread-write, read only, or write only

13.14 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
A Kernel I/O StructureA Kernel I/O Structure

13.15 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Characteristics of I/O DevicesCharacteristics of I/O Devices

13.16 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Block and Character DevicesBlock and Character Devices
nBlock devices include disk drives
lCommands include read, write, seek
lRaw I/O or file-system access
lMemory-mapped file access possible
nCharacter devices include keyboards, mice, serial ports
lCommands include get, put
lLibraries layered on top allow line editing

13.17 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Network DevicesNetwork Devices
nVarying enough from block and character to have own interface
nUnix and Windows NT/9x/2000 include socket interface
lSeparates network protocol from network operation
lIncludes select functionality
nApproaches vary widely (pipes, FIFOs, streams, queues,
mailboxes)

13.18 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Clocks and TimersClocks and Timers
nProvide current time, elapsed time, timer
nProgrammable interval timer used for timings, periodic
interrupts
nioctl (on UNIX) covers odd aspects of I/O such as clocks and
timers

13.19 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Blocking and Nonblocking I/OBlocking and Nonblocking I/O
nBlocking - process suspended until I/O completed
lEasy to use and understand
lInsufficient for some needs
nNonblocking - I/O call returns as much as available
lUser interface, data copy (buffered I/O)
lImplemented via multi-threading
lReturns quickly with count of bytes read or written
nAsynchronous - process runs while I/O executes
lDifficult to use
lI/O subsystem signals process when I/O completed

13.20 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Two I/O MethodsTwo I/O Methods
Synchronous Asynchronous

13.21 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Kernel I/O SubsystemKernel I/O Subsystem
nScheduling
lSome I/O request ordering via per-device queue
lSome OSs try fairness
nBuffering - store data in memory while transferring between devices
lTo cope with device speed mismatch
lTo cope with device transfer size mismatch
lTo maintain “copy semantics”

13.22 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Device-status TableDevice-status Table

13.23 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Sun Enterprise 6000 Device-Transfer Sun Enterprise 6000 Device-Transfer
RatesRates

13.24 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Kernel I/O SubsystemKernel I/O Subsystem
nCaching - fast memory holding copy of data
lAlways just a copy
lKey to performance
nSpooling - hold output for a device
lIf device can serve only one request at a time
li.e., Printing
nDevice reservation - provides exclusive access to a device
lSystem calls for allocation and deallocation
lWatch out for deadlock

13.25 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Error HandlingError Handling
nOS can recover from disk read, device unavailable, transient write
failures
nMost return an error number or code when I/O request fails
nSystem error logs hold problem reports

13.26 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
I/O ProtectionI/O Protection
nUser process may accidentally or purposefully attempt to disrupt
normal operation via illegal I/O instructions
lAll I/O instructions defined to be privileged
lI/O must be performed via system calls
Memory-mapped and I/O port memory locations must be
protected too

13.27 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Use of a System Call to Perform I/OUse of a System Call to Perform I/O

13.28 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Kernel Data StructuresKernel Data Structures
nKernel keeps state info for I/O components, including open file
tables, network connections, character device state
nMany, many complex data structures to track buffers, memory
allocation, “dirty” blocks
nSome use object-oriented methods and message passing to
implement I/O

13.29 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
UNIX I/O Kernel StructureUNIX I/O Kernel Structure

13.30 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
I/O Requests to Hardware I/O Requests to Hardware
OperationsOperations
nConsider reading a file from disk for a process:

lDetermine device holding file
lTranslate name to device representation
lPhysically read data from disk into buffer
lMake data available to requesting process
lReturn control to process

13.31 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Life Cycle of An I/O RequestLife Cycle of An I/O Request

13.32 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
STREAMSSTREAMS
nSTREAM – a full-duplex communication channel between a user-
level process and a device in Unix System V and beyond
nA STREAM consists of:
- STREAM head interfaces with the user process
- driver end interfaces with the device
- zero or more STREAM modules between them.
nEach module contains a read queue and a write queue
nMessage passing is used to communicate between queues

13.33 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
The STREAMS StructureThe STREAMS Structure

13.34 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
PerformancePerformance
nI/O a major factor in system performance:
lDemands CPU to execute device driver, kernel I/O code
lContext switches due to interrupts
lData copying
lNetwork traffic especially stressful

13.35 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Intercomputer CommunicationsIntercomputer Communications

13.36 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Improving PerformanceImproving Performance
nReduce number of context switches
nReduce data copying
nReduce interrupts by using large transfers, smart controllers,
polling
nUse DMA
nBalance CPU, memory, bus, and I/O performance for highest
throughput

13.37 Silberschatz, Galvin and Gagne
©2005
Operating System Concepts – 7
th
Edition, Jan 2, 2005
Device-Functionality ProgressionDevice-Functionality Progression

End of Chapter 13End of Chapter 13