I/O Systems Maciej Sałata 2006. I/O Systems PART I – Abstract aroach I/O Hardware Application I/O...
-
Upload
makayla-flood -
Category
Documents
-
view
223 -
download
1
Transcript of I/O Systems Maciej Sałata 2006. I/O Systems PART I – Abstract aroach I/O Hardware Application I/O...
I/O Systems
Maciej Sałata 2006
I/O Systems
PART I – Abstract aroach I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware
Operations Streams PerformancePART II – Real-life PC I/O hardware
PART I
Abstract approach
Based on Operating System Concepts by Avi Silberschatz, Peter Baer Galvin and Greg Gagne
http://codex.cs.yale.edu/avi/os-book/os7/
I/O Hardware
Incredible variety of I/O devices Common concepts
Port Bus (daisy chain or shared direct access)Controller (host adapter)
I/O instructions control devices Devices have addresses, used by
Direct I/O instructionsMemory-mapped I/O
A Typical PC Bus Structure
Device I/O Port Locations on PCs (partial)
Polling
Determines state of device command-readybusyError
Busy-wait cycle to wait for I/O from device
Interrupts CPU Interrupt-request line triggered by I/O device Interrupt handler receives interrupts Maskable to ignore or delay some interrupts
Interrupt vector to dispatch interrupt to correct handlerBased on prioritySome nonmaskable
Interrupt mechanism also used for exceptions
Interrupt-Driven I/O Cycle
Direct Memory Access
Used to avoid programmed I/O for large data movement
Requires DMA controller
Bypasses CPU to transfer data directly between I/O device and memory
Six Step Process to Perform DMA Transfer
Application I/O Interface
I/O system calls encapsulate device behaviors in generic classes
Device-driver layer hides differences among I/O controllers from kernel
Devices vary in many dimensionsCharacter-stream or blockSequential or random-accessSharable or dedicatedSpeed of operationread-write, read only, or write only
A Kernel I/O Structure
Characteristics of I/O Devices
Block and Character Devices
Block devices include disk drivesCommands include read, write, seek Raw I/O or file-system accessMemory-mapped file access possible
Character devices include keyboards, mice, serial portsCommands include get, putLibraries layered on top allow line editing
Blocking and Nonblocking I/O Blocking - process suspended until I/O completed
Easy to use and understand Insufficient for some needs
Nonblocking - I/O call returns as much as availableUser interface, data copy (buffered I/O) Implemented via multi-threadingReturns quickly with count of bytes read or written
Blocking and Nonblocking I/O
Asynchronous - process runs while I/O executesDifficult to use I/O subsystem signals process when I/O
completed
Two I/O Methods
Synchronous Asynchronous
Kernel I/O Subsystem
SchedulingSome I/O request ordering via per-device queueSome OSs try fairness
Buffering - store data in memory while transferring between devicesTo cope with device speed mismatchTo cope with device transfer size mismatchTo maintain “copy semantics”
Kernel I/O Subsystem Caching - fast memory holding copy of data
Always just a copyKey to performance
Spooling - hold output for a device If device can serve only one request at a time i.e., Printing
Device reservation - provides exclusive access to a deviceSystem calls for allocation and deallocationWatch out for deadlock
Error Handling
OS can recover from disk read, device unavailable, transient write failures
Most return an error number or code when I/O request fails
System error logs hold problem reports
I/O Protection
User process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructionsAll I/O instructions defined to be privileged I/O must be performed via system calls
Memory-mapped and I/O port memory locations must be protected too
I/O Requests to Hardware Operations Consider reading a file from disk for a
process: Determine device holding file Translate name to device representationPhysically read data from disk into bufferMake data available to requesting processReturn control to process
Life Cycle of An I/O Request
STREAMS
STREAM – a full-duplex communication channel between a user-level process and a device in Unix System V and beyond
A STREAM consists of:
- STREAM head interfaces with the user process
- driver end interfaces with the device- zero or more STREAM modules between them.
STREAMS
Each module contains a read queue and a write queue
Message passing is used to communicate between queues
The STREAMS Structure
Performance
I/O a major factor in system performance:
Demands CPU to execute device driver, kernel I/O code
Context switches due to interruptsData copyingNetwork traffic especially stressful
Intercomputer Communications
Improving Performance
Reduce number of context switches Reduce data copying Reduce interrupts by using large transfers,
smart controllers, polling Use DMA Balance CPU, memory, bus, and I/O
performance for highest throughput
PART II
Real-life PC I/O hardware
Based on various articles from Wikipediahttp://wikipedia.org
Drive interfaces
Allow to communicate with disk/optical drives
Short-ranged (with exceptions)
ATA (parallel)
Developed in late 80’s by Western Digital Integrated Drive Electronics (IDE) AT Attachment Packet Interface Bandwidth – up to 133 MB/s (UDMA-133)
SCSI
Developed in 1986 Special controller needed Bandwidth – from 1.5 MB/s (SCSI 1) to
640 MB/s (Ultra-640 SCSI)
SATA
Introduced in 2001 Hot-pluggable Natively supports command queueing Bandwidth – from 150 MB/s to 300 MB/s
Fibre Channel
Used for SANs Despite its name, runs on copper twisted-
pair cables too Topologies
Point-to-point (vide ordinary ATA)Arbitrated loop (vide token ring)Switched fabric (vide ethernet)
System buses
Used for communication with peripheral devices
Allow to extend functionality High bandwidth
ISA (Industry Standard Arch.)
Obsolete nowadays Bandwidth – from 4.77 MB/s (8-bit)
to 16.67 MB/s (16-bit)
PCI
Bandwidth – 133 MB/s (32-bit/33MHz) up to 533 MB/s (64-bit/66MHz)
Improvement – PCI-X
AGP
Designed to cope with big throughput required by video cards
Bandwidth – 266 MB/s (1x) up to2133 MB/s (8x)
PCI-X („Extended”)
Connector physically identical to PCI Do not confuse with PCI Express Bandwidth – up to 4.27 GB/s
PCI Express
Fast and robust Comes in many flavors – from 1x to 16x
(250 MB/s – 8GB/s)
External interfaces
Hot-pluggable (most of them) Allow further extension of functionality plus
additional convenience of use
Serial Port (RS-232)
Standard port used for serial communication, e.g.:Between a computer and a character deviceBetween two computers
Bandwidth – up to 115,200 bps
Parallel port
Transmits several bits in parallel (as the name suggests)
Omitted in modern computers Bandwidth – from 360 kBps to 2.5 MBps
PS/2
DIN/RS-232 replacement Not hot-pluggable Bandwidth – 40 kB/s Used for mice/keyboards
Universal Serial Bus
1.0 – about 0.2 MB/s 1.1 – 1.5 MB/s („Full-speed”) 2.0 – 60 MB/s („High-speed”) Power supply over bus
IEEE 1394 (FireWire , i.Link )
Similar to USB Bandwidth – up to 50 MB/s 1394b – 100 MB/s – 400 MB/s
The End
Any questions?