Computer Operating System - Chapter 12: I/O Systems
Overview
■ I/O Hardware
■ Application I/O Interface
■ Kernel I/O Subsystem
■ Transforming I/O Requests to Hardware Operations
■ STREAMS
■ Performance
■ I/O Hardware
■ Application I/O Interface
■ Kernel I/O Subsystem
■ Transforming I/O Requests to Hardware Operations
■ STREAMS
■ Performance
Bạn đang xem 20 trang mẫu của tài liệu "Computer Operating System - Chapter 12: I/O Systems", để tải tài liệu gốc về máy hãy click vào nút Download ở trên.
File đính kèm:
- computer_operating_system_chapter_12_io_systems.pdf
Nội dung text: Computer Operating System - Chapter 12: I/O Systems
- Chapter 12: I/O Systems ■ Overview ■ I/O Hardware ■ Application I/O Interface ■ Kernel I/O Subsystem ■ Transforming I/O Requests to Hardware Operations ■ STREAMS ■ Performance Operating System Concepts 12.2 Silberschatz, Galvin and Gagne ©2018
- Overview ■ I/O management is a major component of operating system design and operation ● Important aspect of computer operation ● I/O devices vary greatly ● Various methods to control them ● Performance management ● New types of devices frequent ■ Ports, busses, device controllers connect to various devices ■ Device drivers encapsulate device details ● Present uniform device-access interface to I/O subsystem Operating System Concepts 12.4 Silberschatz, Galvin and Gagne ©2018
- A Typical PC Bus Structure Operating System Concepts 12.6 Silberschatz, Galvin and Gagne ©2018
- Device I/O Port Locations on PCs (partial) Operating System Concepts 12.8 Silberschatz, Galvin and Gagne ©2018
- Interrupts ■ Polling can happen in 3 instruction cycles ● Read status, logical-and to extract status bit, branch if not zero ● How to be more efficient if non-zero infrequently? ■ CPU Interrupt-request line triggered by I/O device ● Checked by CPU after each instruction ■ Interrupt handler receives interrupts ● Maskable to ignore or delay some interrupts ■ Interrupt vector to dispatch interrupt to correct handler ● Context switch at start and end ● Based on priority ● Some nonmaskable ● Interrupt chaining if more than one device at same interrupt number Operating System Concepts 12.10 Silberschatz, Galvin and Gagne ©2018
- Interrupts (Cont.) ■ Interrupt mechanism also used for exceptions ● Terminate process, crash system due to hardware error ■ Page fault executes when memory access error ■ System call executes via trap to trigger kernel to execute request ■ Multi-CPU systems can process interrupts concurrently ● If operating system designed to handle it ■ Used for time-sensitive processing, frequent, must be fast Operating System Concepts 12.12 Silberschatz, Galvin and Gagne ©2018
- Intel Pentium Processor Event-Vector Table Operating System Concepts 12.14 Silberschatz, Galvin and Gagne ©2018
- 6 Step Process to Perform DMA Transfer Operating System Concepts 12.16 Silberschatz, Galvin and Gagne ©2018
- A Kernel I/O Structure Operating System Concepts 12.18 Silberschatz, Galvin and Gagne ©2018
- Characteristics of I/O Devices (Cont.) ■ Subtleties of devices handled by device drivers ■ Broadly I/O devices can be grouped by the OS into ● Block I/O ● Character I/O (Stream) ● Memory-mapped file access ● Network sockets ■ For direct manipulation of I/O device specific characteristics, usually an escape / back door ● Unix ioctl() call to send arbitrary bits to a device control register and data to device data register ■ UNIX and Linux use tuple of “major” and “minor” device numbers to identify type and instance of devices (here major 8 and minors 0-4) % ls –l /dev/sda* Operating System Concepts 12.20 Silberschatz, Galvin and Gagne ©2018
- Network Devices ■ Varying enough from block and character to have own interface ■ Linux, Unix, Windows and many others include socket interface ● Separates network protocol from network operation ● Includes select() functionality ■ Approaches vary widely (pipes, FIFOs, streams, queues, mailboxes) Operating System Concepts 12.22 Silberschatz, Galvin and Gagne ©2018
- Nonblocking and Asynchronous 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 available ● User interface, data copy (buffered I/O) ● Implemented via multi-threading ● Returns quickly with count of bytes read or written ● select() to find if data ready then read() or write() to transfer ■ Asynchronous – process runs while I/O executes ● Difficult to use ● I/O subsystem signals process when I/O completed Operating System Concepts 12.24 Silberschatz, Galvin and Gagne ©2018
- Vectored I/O ■ Vectored I/O allows one system call to perform multiple I/O operations ■ For example, Unix readve() accepts a vector of multiple buffers to read into or write from ■ This scatter-gather method better than multiple individual I/O calls ● Decreases context switching and system call overhead ● Some versions provide atomicity 4 Avoid for example worry about multiple threads changing data as reads / writes occurring Operating System Concepts 12.26 Silberschatz, Galvin and Gagne ©2018
- Device-status Table Operating System Concepts 12.28 Silberschatz, Galvin and Gagne ©2018
- Kernel I/O Subsystem ■ Caching – faster device holding copy of data ● Always just a copy ● Key to performance ● Sometimes combined with buffering ■ 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 device ● System calls for allocation and de-allocation ● Watch out for deadlock Operating System Concepts 12.30 Silberschatz, Galvin and Gagne ©2018
- I/O Protection ■ User process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructions ● All I/O instructions defined to be privileged ● I/O must be performed via system calls 4 Memory-mapped and I/O port memory locations must be protected too Operating System Concepts 12.32 Silberschatz, Galvin and Gagne ©2018
- Kernel Data Structures ■ Kernel keeps state info for I/O components, including open file tables, network connections, character device state ■ Many, many complex data structures to track buffers, memory allocation, dirty blocks ■ Some use object-oriented methods and message passing to implement I/O ● Windows uses message passing 4 Message with I/O information passed from user mode into kernel 4 Message modified as it flows through to device driver and back to process 4 Pros / cons? Operating System Concepts 12.34 Silberschatz, Galvin and Gagne ©2018
- Power Management ■ Not strictly domain of I/O, but much is I/O related ■ Computers and devices use electricity, generate heat, frequently require cooling ■ OSes can help manage and improve use ● Cloud computing environments move virtual machines between servers 4 Can end up evacuating whole systems and shutting them down ■ Mobile computing has power management as first class OS aspect Operating System Concepts 12.36 Silberschatz, Galvin and Gagne ©2018
- Kernel I/O Subsystem Summary ■ In summary, the I/O subsystem coordinates an extensive collection of services that are available to applications and to other parts of the kernel 4 Management of the name space for files and devices 4 Access control to files and devices 4 Operation control (for example, a modem cannot seek()) 4 File-system space allocation 4 Device allocation 4 Buffering, caching, and spooling 4 I/O scheduling 4 Device-status monitoring, error handling, and failure recovery 4 Device-driver configuration and initialization 4 Power management of I/O devices ■ The upper levels of the I/O subsystem access devices via the uniform interface provided by the device drivers Operating System Concepts 12.38 Silberschatz, Galvin and Gagne ©2018
- Life Cycle of An I/O Request Operating System Concepts 12.40 Silberschatz, Galvin and Gagne ©2018
- The STREAMS Structure Operating System Concepts 12.42 Silberschatz, Galvin and Gagne ©2018
- Intercomputer Communications Operating System Concepts 12.44 Silberschatz, Galvin and Gagne ©2018
- Device-Functionality Progression Operating System Concepts 12.46 Silberschatz, Galvin and Gagne ©2018
- Summary ■ The basic hardware elements involved in I/O are buses, device controllers, and the devices themselves. ■ The work of moving data between devices and main memory is performed by the CPU as programmed I/O or is offloaded to a DMA controller. ■ The kernel module that controls a device is a device driver. The system-call interface provided to applications is designed to handle several basic categories of hardware, including block devices, character-stream devices, memory-mapped files, network sockets, and programmed interval timers. The system calls usually block the processes that issue them, but nonblock- ing and asynchronous calls are used by the kernel itself and by applications that must not sleep while waiting for an I/O operation to complete. ■ The kernel’s I/O subsystem provides numerous services. Among these are I/O scheduling, buffering, caching, spooling, device reservation, error handling. Another service, name translation, makes the connections between hardware devices and the symbolic file names used by applications. Operating System Concepts 12.48 Silberschatz, Galvin and Gagne ©2018
- End of Chapter 12 Operating System Concepts Silberschatz, Galvin and Gagne ©2018