Home|Contents|Prev|Next|Chat


CSC 711 Answers 3 - I/O subsystem

OS-Q3 Layered I/O subsystem

Each layer hides the layer below and offers a cleaner service above (top to bottom):

  1. User-level I/O software: library calls (printf, fread), spoolers, daemons.
  2. Device-independent OS software: buffering, caching, spooling, naming, protection, block-size independence, error reporting.
  3. Device drivers: device-specific code: translate requests to device commands, manage queues, handle status/errors, present a uniform interface.
  4. Interrupt handlers: respond to completion/error interrupts, acknowledge the controller, wake the waiting process.
  5. Device controllers: hardware registers + local buffer that operate the device.
  6. Physical device.

Requests flow down; interrupts/completions flow up. The lowest software layer (interrupt handler) is minimal and fast; the driver holds device knowledge; the device-independent layer gives the logical, device-neutral interface.

OS-Q3b DMA and the uniform interface

DMA: with programmed/interrupt I/O the CPU moves one byte/word at a time and is interrupted per transfer. DMA offloads this: the driver programs the DMA controller (memory address, device address, count, direction) and is free to do other work; the controller moves a whole block between the device buffer and memory using cycle stealing, raising only one interrupt per block. Benefits: higher throughput, far lower CPU overhead, overlap of I/O and computation. Trade-off: bus/memory contention and cache coherence.

Uniform interface: devices differ (block vs char, speed, commands, errors). Without a uniform interface the OS would be unmaintainable. A common interface (open/read/write/close/ioctl; block/char abstractions) gives abstraction, portability, code reuse and separation of concerns; ioctl is the escape hatch.

Key point: DMA removes the CPU from data movement; the uniform interface removes the device's identity from higher-level software.


Home|Contents|Prev|Next|Top|Chat