operating-systems io

Definition

IO Management

IO management is the OS task of managing interaction between the processor and peripheral devices, providing a uniform interface while handling device diversity.

Device Categories

Human-Readable

Communication with users (keyboards, displays, printers).

Machine-Readable

Electronic communication and data storage (disk drives, sensors, actuators).

Communication

Data exchange with remote devices (network interfaces, modems).

Device Characteristics

IO Complexity

Managing IO is complex due to extreme variations in:

  • Data Rate: Orders of magnitude difference (keyboard vs. Gigabit Ethernet)
  • Application: Context-dependent usage (file system vs. swap space)
  • Control Complexity: Simple polling to complex interrupt handling
  • Unit of Transfer: Byte streams vs. fixed-size blocks
  • Data Representation: Byte order, encoding, parity
  • Error Handling: Error types and recovery mechanisms

Design Objectives

Efficiency

IO is often the bottleneck. Buffering and disk scheduling bridge the speed gap.

Generality

Uniform interface (open, close, read, write) hides device details, simplifying development and replacement.

Reliability

Ensures data integrity and graceful handling of hardware failures.

IO Modes

Blocking IO

Calling process moves to Blocked state until IO completes.

Non-blocking IO

System call returns immediately; status indicates completion or bytes transferred.

Synchronous IO

Process is conceptually tied to IO completion (even with polling).

Asynchronous IO

Process triggers request and continues; OS notifies on completion (signal or callback).

Request Sequence

Synchronous IO Flow

  1. User Request: Application issues system call (e.g., read())
  2. Kernel Check: Check if request satisfied from cache
  3. Driver Initiation: Block process, send commands to device driver
  4. Controller Command: Configure device controller for transfer
  5. Hardware Execution: Device performs physical IO
  6. Completion Interrupt: Controller generates interrupt
  7. Data Transfer: Handler copies data to kernel buffer, then to user space
  8. Unblock: Process moved to Ready state