Bài giảng Operating system Concepts - Chapter 13: I/O Systems
Bạn đang xem 20 trang mẫu của tài liệu "Bài giảng Operating system Concepts - Chapter 13: I/O Systems", để tải tài liệu gốc về máy bạn click vào nút DOWNLOAD ở trên
Tài liệu đính kèm:
- bai_giang_operating_system_concepts_chapter_13_io_systems.ppt
Nội dung text: Bài giảng Operating system Concepts - Chapter 13: I/O Systems
- Chapter 13: I/O Systems n I/O Hardware n Application I/O Interface n Kernel I/O Subsystem n Transforming I/O Requests to Hardware Operations n Streams n Performance Operating System Concepts 13.1 Silberschatz, Galvin and Gagne 2002
- I/O Hardware n Incredible variety of I/O devices n Common concepts F Port F Bus (daisy chain or shared direct access) F Controller (host adapter) n I/O instructions control devices n Devices have addresses, used by F Direct I/O instructions F Memory-mapped I/O Operating System Concepts 13.2 Silberschatz, Galvin and Gagne 2002
- A Typical PC Bus Structure Operating System Concepts 13.3 Silberschatz, Galvin and Gagne 2002
- Device I/O Port Locations on PCs (partial) Operating System Concepts 13.4 Silberschatz, Galvin and Gagne 2002
- Polling n Determines state of device F command-ready F busy F Error n Busy-wait cycle to wait for I/O from device Operating System Concepts 13.5 Silberschatz, Galvin and Gagne 2002
- Interrupts n CPU Interrupt request line triggered by I/O device n Interrupt handler receives interrupts n Maskable to ignore or delay some interrupts n Interrupt vector to dispatch interrupt to correct handler F Based on priority F Some unmaskable n Interrupt mechanism also used for exceptions Operating System Concepts 13.6 Silberschatz, Galvin and Gagne 2002
- Interrupt-Driven I/O Cycle Operating System Concepts 13.7 Silberschatz, Galvin and Gagne 2002
- Intel Pentium Processor Event-Vector Table Operating System Concepts 13.8 Silberschatz, Galvin and Gagne 2002
- Direct Memory Access n Used to avoid programmed I/O for large data movement n Requires DMA controller n Bypasses CPU to transfer data directly between I/O device and memory Operating System Concepts 13.9 Silberschatz, Galvin and Gagne 2002
- Six Step Process to Perform DMA Transfer Operating System Concepts 13.10 Silberschatz, Galvin and Gagne 2002
- Application I/O Interface n I/O system calls encapsulate device behaviors in generic classes n Device-driver layer hides differences among I/O controllers from kernel n Devices vary in many dimensions F Character-stream or block F Sequential or random-access F Sharable or dedicated F Speed of operation F read-write, read only, or write only Operating System Concepts 13.11 Silberschatz, Galvin and Gagne 2002
- A Kernel I/O Structure Operating System Concepts 13.12 Silberschatz, Galvin and Gagne 2002
- Characteristics of I/O Devices Operating System Concepts 13.13 Silberschatz, Galvin and Gagne 2002
- Block and Character Devices n Block devices include disk drives F Commands include read, write, seek F Raw I/O or file-system access F Memory-mapped file access possible n Character devices include keyboards, mice, serial ports F Commands include get, put F Libraries layered on top allow line editing Operating System Concepts 13.14 Silberschatz, Galvin and Gagne 2002
- Network Devices n Varying enough from block and character to have own interface n Unix and Windows NT/9i/2000 include socket interface F Separates network protocol from network operation F Includes select functionality n Approaches vary widely (pipes, FIFOs, streams, queues, mailboxes) Operating System Concepts 13.15 Silberschatz, Galvin and Gagne 2002
- Clocks and Timers n Provide current time, elapsed time, timer n If programmable interval time used for timings, periodic interrupts n ioctl (on UNIX) covers odd aspects of I/O such as clocks and timers Operating System Concepts 13.16 Silberschatz, Galvin and Gagne 2002
- Blocking and Nonblocking I/O n Blocking - process suspended until I/O completed F Easy to use and understand F Insufficient for some needs n Nonblocking - I/O call returns as much as available F User interface, data copy (buffered I/O) F Implemented via multi-threading F Returns quickly with count of bytes read or written n Asynchronous - process runs while I/O executes F Difficult to use F I/O subsystem signals process when I/O completed Operating System Concepts 13.17 Silberschatz, Galvin and Gagne 2002
- Kernel I/O Subsystem n Scheduling F Some I/O request ordering via per-device queue F Some OSs try fairness n Buffering - store data in memory while transferring between devices F To cope with device speed mismatch F To cope with device transfer size mismatch F To maintain “copy semantics” Operating System Concepts 13.18 Silberschatz, Galvin and Gagne 2002
- Sun Enterprise 6000 Device-Transfer Rates Operating System Concepts 13.19 Silberschatz, Galvin and Gagne 2002
- Kernel I/O Subsystem n Caching - fast memory holding copy of data F Always just a copy F Key to performance n Spooling - hold output for a device F If device can serve only one request at a time F i.e., Printing n Device reservation - provides exclusive access to a device F System calls for allocation and deallocation F Watch out for deadlock Operating System Concepts 13.20 Silberschatz, Galvin and Gagne 2002
- Error Handling n OS can recover from disk read, device unavailable, transient write failures n Most return an error number or code when I/O request fails n System error logs hold problem reports Operating System Concepts 13.21 Silberschatz, Galvin and Gagne 2002
- Kernel Data Structures n Kernel keeps state info for I/O components, including open file tables, network connections, character device state n Many, many complex data structures to track buffers, memory allocation, “dirty” blocks n Some use object-oriented methods and message passing to implement I/O Operating System Concepts 13.22 Silberschatz, Galvin and Gagne 2002
- UNIX I/O Kernel Structure Operating System Concepts 13.23 Silberschatz, Galvin and Gagne 2002
- I/O Requests to Hardware Operations n Consider reading a file from disk for a process: F Determine device holding file F Translate name to device representation F Physically read data from disk into buffer F Make data available to requesting process F Return control to process Operating System Concepts 13.24 Silberschatz, Galvin and Gagne 2002
- Life Cycle of An I/O Request Operating System Concepts 13.25 Silberschatz, Galvin and Gagne 2002
- STREAMS n STREAM – a full-duplex communication channel between a user-level process and a device n A STREAM consists of: - STREAM head interfaces with the user process - driver end interfaces with the device - zero or more STREAM modules between them. n Each module contains a read queue and a write queue n Message passing is used to communicate between queues Operating System Concepts 13.26 Silberschatz, Galvin and Gagne 2002
- The STREAMS Structure Operating System Concepts 13.27 Silberschatz, Galvin and Gagne 2002
- Performance n I/O a major factor in system performance: F Demands CPU to execute device driver, kernel I/O code F Context switches due to interrupts F Data copying F Network traffic especially stressful Operating System Concepts 13.28 Silberschatz, Galvin and Gagne 2002
- Intercomputer Communications Operating System Concepts 13.29 Silberschatz, Galvin and Gagne 2002
- Improving Performance n Reduce number of context switches n Reduce data copying n Reduce interrupts by using large transfers, smart controllers, polling n Use DMA n Balance CPU, memory, bus, and I/O performance for highest throughput Operating System Concepts 13.30 Silberschatz, Galvin and Gagne 2002
- Device-Functionality Progression Operating System Concepts 13.31 Silberschatz, Galvin and Gagne 2002