← Back to Universe Map

🔌 I/O & Devices Planet

Interrupts, Device Drivers, DMA, and I/O Management

🌟 What is This Planet?

The I/O planet explores how the OS communicates with devices like keyboards, disks, network cards, and displays using interrupts and device drivers.

You'll understand:

  • How interrupts work
  • Device drivers and their role
  • Polling vs interrupt-driven I/O
  • DMA (Direct Memory Access)
  • I/O buffering
  • Asynchronous I/O

📚 Core Concepts

Interrupt: Hardware signal that CPU must handle immediately

Device Driver: OS code that knows how to control a specific device

Interrupt Handler: Kernel code that runs when interrupt fires

DMA: Device transfers data directly to RAM without CPU

I/O Blocking: Process waits (WAITING state) for I/O to complete

Async I/O: Process continues while I/O happens in background

🧠 The Mental Model

Think of I/O devices like delivery trucks:

  • Device = truck bringing data
  • Interrupt = doorbell ring (device is ready)
  • Device driver = person who knows how to talk to that truck company
  • DMA = truck drops package directly at your door (no CPU needed)
  • Process blocks = you wait at door for delivery

⚡ Key Flows

Interrupt-Driven I/O:

  1. Process calls read()
  2. Kernel asks device to start read
  3. Process moves to WAITING
  4. Device reads data (slow)
  5. Device sends interrupt to CPU
  6. Kernel handles interrupt
  7. Process moves to READY

DMA Transfer:

  1. Kernel sets up DMA controller
  2. DMA reads from device → writes to RAM
  3. CPU free to do other work
  4. DMA sends interrupt when done
  5. Kernel processes completed transfer

🔗 Connection to OS

When a process does I/O:

  • Process calls system call (read, write)
  • Kernel invokes device driver
  • Driver programs the device
  • Process blocks if waiting for data
  • Device interrupt wakes process later

This is why I/O is "expensive" - context switches, waiting, interrupts all add overhead.

🎯 Real Examples

Keyboard: Each keypress generates interrupt

Network card: Receives packet → interrupt → kernel processes

Disk: read() blocks process → disk interrupt → process ready

Display: GPU writes directly to video RAM (DMA-like)

USB: Devices hotplug → driver loads → device ready

🚧 Interactive I/O Simulator Coming Soon

We're building an interactive I/O visualization that will let you: