113.1Silberschatz, Galvin and Gagne ©2005Operating System ConceptsCSMC 412CSMC 412Operating SystemsProf. Ashok K Agrawala© 2005 Ashok AgrawalaSet 1313.2Silberschatz, Galvin and Gagne ©2005Operating System ConceptsI/O SystemsI/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware Operations Streams Performance213.3Silberschatz, Galvin and Gagne ©2005Operating System ConceptsObjectivesObjectives Explore the structure of an operating system’s I/O subsystem Discuss the principles of I/O hardware and its complexity Provide details of the performance aspects of I/O hardware and software13.4Silberschatz, Galvin and Gagne ©2005Operating System ConceptsI/O HardwareI/O Hardware Incredible variety of I/O devices Common conceptsz Portz Bus (daisy chain or shared direct access)z Controller (host adapter) I/O instructions control devices Devices have addresses, used by z Direct I/O instructionsz Memory-mapped I/O313.5Silberschatz, Galvin and Gagne ©2005Operating System ConceptsA Typical PC Bus StructureA Typical PC Bus Structure13.6Silberschatz, Galvin and Gagne ©2005Operating System ConceptsDevice I/O Port Locations on PCs (partial)Device I/O Port Locations on PCs (partial)413.7Silberschatz, Galvin and Gagne ©2005Operating System ConceptsPollingPolling Determines state of device z command-readyz busyz Error Busy-wait cycle to wait for I/O from device13.8Silberschatz, Galvin and Gagne ©2005Operating System ConceptsInterruptsInterrupts 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 handlerz Based on priorityz Some non-maskable Interrupt mechanism also used for exceptions513.9Silberschatz, Galvin and Gagne ©2005Operating System ConceptsInterruptInterrupt--Driven I/O CycleDriven I/O Cycle13.10Silberschatz, Galvin and Gagne ©2005Operating System ConceptsIntel Pentium Processor EventIntel Pentium Processor Event--Vector TableVector Table613.11Silberschatz, Galvin and Gagne ©2005Operating System ConceptsDirect Memory AccessDirect 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 13.12Silberschatz, Galvin and Gagne ©2005Operating System ConceptsSix Step Process to Perform DMA TransferSix Step Process to Perform DMA Transfer713.13Silberschatz, Galvin and Gagne ©2005Operating System ConceptsApplication I/O InterfaceApplication 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 dimensionsz Character-stream or blockz Sequential or random-accessz Sharable or dedicatedz Speed of operationz read-write, read only, or write only13.14Silberschatz, Galvin and Gagne ©2005Operating System ConceptsA Kernel I/O StructureA Kernel I/O Structure813.15Silberschatz, Galvin and Gagne ©2005Operating System ConceptsCharacteristics of I/O DevicesCharacteristics of I/O Devices13.16Silberschatz, Galvin and Gagne ©2005Operating System ConceptsBlock and Character DevicesBlock and Character Devices Block devices include disk drivesz Commands include read, write, seek z Raw I/O or file-system accessz Memory-mapped file access possible Character devices include keyboards, mice, serial portsz Commands include get, putz Libraries layered on top allow line editing913.17Silberschatz, Galvin and Gagne ©2005Operating System ConceptsNetwork DevicesNetwork Devices Varying enough from block and character to have own interface Unix and Windows NT/9x/2000 include socket interfacez Separates network protocol from network operationz Includes select functionality Approaches vary widely (pipes, FIFOs, streams, queues, mailboxes)13.18Silberschatz, Galvin and Gagne ©2005Operating System ConceptsClocks and TimersClocks and Timers Provide current time, elapsed time, timer Programmable interval timer used for timings, periodic interrupts ioctl (on UNIX) covers odd aspects of I/O such as clocks and timers1013.19Silberschatz, Galvin and Gagne ©2005Operating System ConceptsBlocking and Nonblocking I/OBlocking and Nonblocking I/O Blocking - process suspended until I/O completedz Easy to use and understandz Insufficient for some needs Nonblocking - I/O call returns as much as availablez User interface, data copy (buffered I/O)z Implemented via multi-threadingz Returns quickly with count of bytes read or written Asynchronous - process runs while I/O executesz Difficult to usez I/O subsystem signals process when I/O completed13.20Silberschatz, Galvin and Gagne ©2005Operating System ConceptsTwo I/O MethodsTwo I/O MethodsSynchronousAsynchronous1113.21Silberschatz, Galvin and Gagne ©2005Operating System ConceptsKernel I/O SubsystemKernel I/O Subsystem Schedulingz Some I/O request ordering via per-device queuez Some OSs try fairness Buffering - store data in memory while transferring between devicesz To cope with device speed mismatchz To cope with device transfer size mismatchz To maintain “copy semantics”13.22Silberschatz, Galvin and Gagne ©2005Operating System ConceptsDeviceDevice--status Tablestatus Table1213.23Silberschatz, Galvin and Gagne ©2005Operating System ConceptsSun Enterprise 6000 DeviceSun Enterprise 6000 Device--Transfer RatesTransfer Rates13.24Silberschatz, Galvin and Gagne ©2005Operating System ConceptsKernel I/O SubsystemKernel I/O Subsystem Caching - fast memory holding copy of dataz Always just a copyz Key to performance Spooling - hold output for a devicez If device can serve only one request at a time z i.e., Printing Device reservation - provides exclusive access to a devicez System calls for allocation and deallocationz Watch out for deadlock1313.25Silberschatz, Galvin and Gagne ©2005Operating System ConceptsError HandlingError 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 reports13.26Silberschatz, Galvin and Gagne ©2005Operating System ConceptsI/O ProtectionI/O Protection User process may accidentally or purposefully attempt to disruptnormal operation via illegal I/O instructionsz All I/O instructions defined to be
View Full Document