SeriesOperating Systems11 / 16

IO Management

Module 11 of CS 6200 - Graduate Introduction to Operating Systems @ Georgia Tech.

Overview#

I/O Management refers to the abstraction and arbitration of any input / output (I/O) device by the operating system. I/O management can take many different forms:

We define an I/O device as any device which provides input and/or receives output within a computing system. Example I/O devices include keyboards, mice, displays, the network interface card, etc.

computing-system

Although the I/O device population is extremely diverse, we can describe their typical components using the canonical device model:

OS-Device Interaction#

CPU-Device Interconnect#

In computing, an Interconnect refers to any communication path linking components of the computing system to enable data exchange or system functionality. Devices typically connect to the CPU via some intermediate controller (part of the device hardware), which then links to some central interconnect. For example, the Peripheral Component Interconnect (PCI) is one of the standard methods for connecting devices to the CPU.

interconnect

Interconnections function by representing device registers as memory locations (device registers share same address space as RAM). When the CPU writes to these locations, the integrated PCI detects the access and maps writes to the appropriate device. This general process is known as Memory-Mapped I/O.

So how does the CPU issue instructions to a device?

Drivers#

Device Drivers are device-specific software components which enable the operating system to access / control a device. Drivers are provided by device manufacturers, and must be provided for each OS. The OS typically provides an interface to define the set of standards / supporting mechanisms for a particular device driver. This serves to 1) provide clear expectations and framework for device driver developers, and 2) enable the OS to support many different device implementations without sacrifice to functionality.

driver

Device Types + OS Representation#

So what types of devices does an OS support? Any OS provides well-defined interfaces for the following device types:

Internally, the OS maintains a representation of each device via a specific device file. For example, device files are stored in the /dev directory of root on UNIX-like platforms. This representation enables the OS to apply any other mechanisms pertaining to file systems to devices (e.g., read/write)!

EVERYTHING IS A FILE IN UNIX-LIKE OPERATING SYSTEMS

Device Integration with User Processes#

Overview#

How can user processes interact with devices? The process must perform a System Call specifying the appropriate operation (e.g., read). The OS must perform necessary preprocessing to prepare any relevant data for transfer, then invoke the device driver. Finally, the device driver issues the appropriate commands to the device. Any results / events originating from the device will traverse the call chain in reverse order back to the user process.

user-process

OS Bypass#

Some devices can be configured to be directly accessible by user programs - this is known as OS Bypass. This approach must use a user-level driver / library for device interaction, since we are not relying on the OS (and its associated drivers) for any direct support. However, the OS does retain some coarse-grain control over the device.

Blocking Status#

What happens when a user process makes a call involving an I/O device? This depends on synchronicity:

Virtual File System#

Overview#

The Virtual File System (VFS) is a layer used by UNIX-like systems to hide all details on the underlying file system from the kernel and user-level applications. For example, this ensures that files appearing across multiple different storage (block) devices appear as a singular unit.

VFS

VFS supports the following key abstractions:

Second Extended Filesystem#

While VFS is the OS subsystem that provides a standardized interface for file interaction, file systems such as ext2 are concrete implementations. Disk partitions organized via the ext2 file system have the following components:

ext2

Inodes#

Any file is uniquely identified by its Inode. The inode contains the indices for all disk blocks corresponding to the file, as well as other file meta-data (ex: permissions, size, etc.). Inodes are uniquely indexed within the file system, meaning we can uniquely identify a file based on inode number.

Inodes contain both direct and indirect pointers to blocks on disk. Direct pointers directly point to data blocks. Indirect pointers point to blocks of more pointers; this means we can support much larger files compared to direct pointers alone!

inode

Disk Access Optimizations#

File systems use various mechanisms to reduce file access overheads. For example, caching/buffering directly reduces the amount of disk accesses by keeping a buffer cache in main memory. I/O scheduling orders disk accesses to reduce disk head movement - the scheduler tends to maximize sequential vs. random block access to keep write operations close to one another. Prefetching leverages locality by reading in proximal blocks (given a single block access), thereby assuming that nearby blocks will also be relevant to the current operation.


(all images obtained from Georgia Tech GIOS course materials)

License

CC BY-NC-SA 4.0 This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Related Posts