I/O Management in Representative Operating Systems 1 UNIX SVR4 I/O Management • Principles – Each I/O device is associated with a special file – Special files are managed by the file system – To read or write to a device, a read or write request is made for a special file associated with the device • Types of I/O – Buffered • I/O passes through system buffers • Types of buffers – System buffer caches – Character queues – Unbuffered • Uses the DMA facility: transfer takes place directly between the I/O module and the process I/O area CS-550 (M.Soneru): I/O Management in Representative Operating Systems: [Sta’01] 2 UNIX SVR4 I/O Management (cont.) CS-550 (M.Soneru): I/O Management in Representative Operating Systems: [Sta’01] 3 UNIX SVR4 I/O Management (cont.) • Buffer cache – All I/O operations with the disk (block oriented) are handled through the buffer cache – Data transfer between the buffer cache and the user process space uses DMA: memory-to-memory copy – Buffer cache management uses three lists • Free List: List of all buffers available for allocation • Device List: List of all buffers currently associated with each disk • Driver I/O Queue: List of buffers in the process of an I/O or waiting for an I/O on a particular device – Implementation • All buffers are either on the free list or on the driver I/O queue list • No physically separate lists: a list is maintained as pointers associated with each buffer • Each buffer is associated with a device and remains associated with that device even on the free list, until reused and associated with another device CS-550 (M.Soneru): I/O Management in Representative Operating Systems: [Sta’01] 4 UNIX SVR4 I/O Management (cont.) • Buffer cache (cont.) – Operation • Uses the readers/writers model: may be read multiple times • On a reference to physical block X on device Y, the OS first checks if the block is in the buffer cache • It searches the Device List for block X on device Y • If entry exists, it contains a pointer to the first buffer in the chain • Block replacement uses a least-recently-used algorithm: the free list maintains the least-recently-used order • Character queue – Used for character-oriented devices (e.g., terminals, printers) – A character queue is either written by the process and read by the I/O device or written by device and read by the process – Producer-consumer model is used: a character, one read, is destroyed CS-550 (M.Soneru): I/O Management in Representative Operating Systems: [Sta’01] 5 UNIX SVR4 I/O Management (cont.) • Unbuffered I/O – Fastest I/O, uses DMA between the process space and the device space – Operation • Process performing unbuffered I/O is locked in main memory and cannot be swapped out • I/O device performing unbuffered I/O is assigned to the process for the duration of the transfer • Types of devices and the buffering used for each – – – – – Disk drives: unbuffered I/O or buffer cache Tape drives: unbuffered I/O or buffer cache Terminals: character queue Communication lines: character queue Printers: unbuffered I/O or character queue CS-550 (M.Soneru): I/O Management in Representative Operating Systems: [Sta’01] 6 Windows 2000 I/O Management • I/O manager – Responsible for all I/O for the OS – Provides uniform interface that all types of drivers can call CS-550 (M.Soneru): I/O Management in Representative Operating Systems: [Sta’01] 7 Windows 2000 I/O Management (cont.) • Cache manager – Provides caching service in main memory for the entire I/O subsystem, serving file systems and network components – It manages the size of the cache for each activity – Provides two services to improve system performance • Lazy write – Writes done in the cache only and not on disk – When processor utilization is low, cache manager writes changes to disk • Lazy commit – Similar to lazy write for transaction processing – Committed information is written in cache only – Background process writes information to the file system log at a later time CS-550 (M.Soneru): I/O Management in Representative Operating Systems: [Sta’01] 8 Windows 2000 I/O Management (cont.) • File system drivers – Treated like any other device driver – Messages for certain volumes routed to the appropriate software driver for that device adapter • Network drivers – Integrated networking capabilities – Support for distributed applications • Hardware device drivers – Access the hardware registers of peripheral devices through entry points in the Executive dynamic link libraries – A set of such routines exists for every platform supported by W2K: routine names are the same for all platforms – Device drivers portable across different platforms CS-550 (M.Soneru): I/O Management in Representative Operating Systems: [Sta’01] 9 Windows 2000 I/O Management (cont.) • Asynchronous and synchronous I/O – Asynchronous mode • Optimum application performance • Application initiates I/O operation and the calling thread continues execution while the I/O operation is queued by the I/O manager and then performed • Application needs to be notified when operation is complete – Synchronous mode • Application is blocked until the I/O operation completes – Methods for signaling I/O completion for the asynchronous mode • Signaling a device kernel object • Signaling an event kernel object • Alertable I/O • I/O completion ports CS-550 (M.Soneru): I/O Management in Representative Operating Systems: [Sta’01] 10 Windows 2000 I/O Management (cont.) • Methods for signaling I/O completion for the asynchronous mode – Signaling a device kernel object • Indicator associated with a device object is set when an operation on that object is complete • The thread that invoked the I/O operation continues execution and then checks the indicator when it needs the outcome of the I/O operation • Method is not appropriate for handling multiple requests on the same device (e.g., multiple actions on a single file) – Signaling an event kernel object • Thread creates event for each request • Thread can then wait on a single or multiple requests • Method is appropriate for handling multiple simultaneous I/O requests on a single device or file CS-550 (M.Soneru): I/O Management in Representative Operating Systems: [Sta’01] 11 Windows 2000 I/O Management (cont.) • Methods for signaling I/O completion for the asynchronous mode (cont.) – Alertable I/O • Uses an Asynchronous Procedure Call (APC) queue associated with the thread • The thread I/O requests and the I/O manager places the results in the APC queue for that thread – I/O completion ports • Used on the W2K server to optimize the use of threads • A pool of threads is available for use: no need to create a new thread for each new request CS-550 (M.Soneru): I/O Management in Representative Operating Systems: [Sta’01] 12 Windows 2000 I/O Management (cont.) • Redundant Array of Independent Disks (RAID) support – Hardware RAID • Separate physical disks combined into one or more logical disks by the disk controller • Controller interface responsible for the creation and regeneration of redundant information – Software RAID • Noncontiguous disk space combined into one or more logical partitions by the fault-tolerant software disk driver • Implemented by the OS and available on the server with any set of multiple disks CS-550 (M.Soneru): I/O Management in Representative Operating Systems: [Sta’01] 13