What is I/O subsystem and device drivers?
Answer
The I/O subsystem manages communication between the OS and all peripheral devices. It provides a uniform interface to diverse hardware through device drivers. I/O Hardware components: I/O port (device registers accessible by CPU), I/O bus (data pathway: PCIe, USB, SATA), controller (interprets high-level commands, drives physical device), DMA controller (transfers data without CPU). I/O techniques: (1) Programmed I/O (polling): CPU continuously checks device status register. Simple but wastes CPU cycles; (2) Interrupt-driven I/O: CPU initiates I/O, continues other work, device interrupts CPU on completion. CPU-efficient for slow devices; (3) DMA (Direct Memory Access): DMA controller transfers data directly between device and memory. CPU only involved to set up transfer and handle completion interrupt. Most efficient for large transfers (disk, network). Device driver role: abstracts specific hardware details; presents a uniform interface to the OS kernel (block device, character device, network interface); translates generic OS requests to device-specific commands; handles interrupts from device; manages device state and buffering. I/O layers (Linux): User Process → POSIX API (read/write) → Virtual File System (VFS) → File System (ext4, NTFS) → Block I/O Layer (I/O scheduler, request queue) → Device Driver → Hardware Controller → Physical Device. Block vs character devices: block devices (disk, SSD) — transfer data in fixed-size blocks, random access, buffered. Character devices (keyboard, serial port, mouse) — transfer one byte at a time, sequential, unbuffered. Network devices: separate category. Buffering: kernel maintains page cache — all file I/O goes through it. Reading: kernel reads block from disk into page cache → copies to user buffer. Writing: user writes to page cache → kernel flushes to disk (sync or async).
Previous
What are Linux namespaces and how do they enable containers?
Next
What is real-time operating systems (RTOS)?
More Operating Systems Questions
View all →- Advanced What is the Linux kernel scheduling (CFS)?
- Advanced What is the difference between mutex, semaphore, and condition variable?
- Advanced What is virtual memory in detail — TLB, page tables, huge pages?
- Advanced What is the boot process of a Linux system?
- Advanced What is NUMA (Non-Uniform Memory Access)?