Operating SystemUnit 710 min read
I/O Systems: Devices, Methods & Performance
Unit 7 of Operating System covers I/O hardware, interrupt-driven I/O, DMA, buffering, spooling, device drivers, and performance metrics (throughput, response time). Learn how OS manages I/O requests efficiently, with real-world examples from eSewa, Daraz, and NTC.
TAKEAWAYS:
- I/O devices communicate with the CPU via interrupts, DMA, or polling, each with trade-offs in speed and overhead.
- Buffering and spooling improve I/O efficiency by decoupling device speed from CPU speed.
- Device drivers act as translators between hardware and OS, handling low-level commands.
- Performance metrics like throughput and response time measure I/O system effectiveness.
- RAID and disk scheduling (e.g., SCAN, C-SCAN) optimize disk access in real-world storage systems.
1. I/O Hardware & Classification
I/O devices transfer data between the CPU/memory and the external world. They are classified based on transfer speed, data representation, and access method.
Classification of I/O Devices
How I/O Devices Communicate with the CPU
I/O devices cannot directly access the CPU. They use one of three methods:
- Programmed I/O (Polling) – CPU repeatedly checks if the device is ready (inefficient).
- Interrupt-Driven I/O – Device sends an interrupt signal when ready (most common).
- Direct Memory Access (DMA) – Device transfers data directly to memory without CPU intervention (used for high-speed devices like disks).
2. Interrupt-Driven I/O (Most Common Method)
When an I/O device completes an operation, it sends an interrupt signal to the CPU. The OS handles this via an Interrupt Service Routine (ISR).
How Interrupt-Driven I/O Works
sequenceDiagram
participant CPU
participant Device
participant OS
CPU->>Device: Sends I/O request
Device-->>CPU: Sends Interrupt (when done)
CPU->>OS: Calls ISR
OS->>Device: Processes data
OS-->>CPU: Returns controlAdvantages & Disadvantages
| Method | Advantages | Disadvantages |
|---|---|---|
| Interrupt-Driven | Efficient CPU usage (no polling) | Overhead of context switching |
| Programmed I/O | Simple implementation | CPU wasted in polling |
| DMA | Faster for bulk transfers (e.g., disks) | Requires special hardware (DMA controller) |
Worked Example: eSewa Payment Processing
- When you pay a bill on eSewa, the app sends a request to the server.
- The server’s disk (an I/O device) stores transaction records.
- Instead of the CPU constantly checking if the disk is ready (polling), the disk sends an interrupt when data is read/written.
- The OS’s ISR processes the transaction and updates the database.
3. Direct Memory Access (DMA)
For high-speed devices (e.g., disks, network cards), the CPU cannot keep up with polling or interrupts. Instead, a DMA controller transfers data directly to memory.
How DMA Works
Advantages of DMA
- Reduces CPU load (no need to handle every byte).
- Faster bulk transfers (e.g., loading an OS from disk).
- Used in network cards, sound cards, and graphics cards.
Real-World Example: Daraz Order Processing
- When you place an order on Daraz, the server’s DMA controller transfers large product databases directly to RAM without CPU intervention.
- This speeds up order processing and reduces delays.
4. Buffering & Spooling (Improving I/O Efficiency)
Buffering
- A temporary storage area in memory or disk to smooth out speed differences between devices.
- Example: A printer buffer holds multiple print jobs before sending them to the printer.
Spooling (Simultaneous Peripheral Operations Online)
- Spooling extends buffering to disk storage for devices like printers.
- Example: When multiple users print documents, the OS spools (queues) them on disk and prints them one by one.
Worked Example: NTC Traffic Management System
- The NTC traffic control system uses spooling to manage multiple traffic signal requests.
- Instead of processing each request immediately (which would overload the CPU), requests are queued (spooled) and processed in order.
5. Device Drivers (Software Interface for Hardware)
A device driver is a software program that allows the OS to communicate with a hardware device.
Functions of a Device Driver
Example: Printer Driver
- When you print a document, the OS sends a generic print command.
- The printer driver converts this into HP PCL or Canon PJL commands.
- The printer then executes the exact instructions.
6. I/O Performance Metrics
| Metric | Definition | Example |
|---|---|---|
| Throughput | Total data transferred per unit time | 100 MB/s (disk speed) |
| Response Time | Time from request to first data | 50 ms (printer response) |
| I/O Bound | Process spends more time waiting for I/O | Database queries, file transfers |
| CPU Bound | Process spends more time in CPU | Scientific computations |
Worked Example: Ncell Data Transfer
- If Ncell’s 4G network has a throughput of 50 Mbps, it means 50 million bits per second can be transferred.
- If a user downloads a 1 GB file, the response time depends on network latency and server speed.
7. Disk Scheduling Algorithms (Optimizing Disk Access)
The OS uses disk scheduling to minimize seek time (time to move the disk head) and rotational latency (time for the right sector to reach the head).
Common Disk Scheduling Algorithms
| Algorithm | Description | Best For |
|---|---|---|
| FCFS | First-Come, First-Served (no optimization) | Simple systems |
| SSTF | Shortest Seek Time First (picks nearest request) | Reduces seek time |
| SCAN | Moves head in one direction, reverses at end (like an elevator) | Balanced performance |
| C-SCAN | Circular SCAN (head moves in one direction only) | Prevents starvation |
| LOOK | Like SCAN but only goes as far as the last request | More efficient than SCAN |
Worked Example: Bank Transaction Logging
- A bank’s database server uses C-SCAN to log transactions efficiently.
- Instead of moving the disk head randomly (FCFS), it moves in a predictable pattern, reducing delays.
8. RAID (Redundant Array of Independent Disks)
RAID improves performance, reliability, and fault tolerance by combining multiple disks.
Common RAID Levels
| RAID Level | Description | Use Case |
|---|---|---|
| RAID 0 | Striping (no redundancy, faster reads/writes) | Temporary storage, speed needs |
| RAID 1 | Mirroring (duplicate data, high reliability) | Critical data (e.g., OS drives) |
| RAID 5 | Striping with parity (fault-tolerant) | Databases, servers |
| RAID 10 | Combines RAID 1 + RAID 0 (mirrored + striped) | High-performance, fault-tolerant systems |
Real-World Example: Cloud Storage (eSewa, Khalti)
- eSewa’s servers use RAID 10 to ensure fast transactions and data redundancy.
- If one disk fails, the system automatically recovers without downtime.
Exam Tip
What to Focus On
✅ Interrupt-Driven I/O vs. DMA – Know when each is used and their advantages. ✅ Buffering vs. Spooling – Understand how they improve efficiency. ✅ Disk Scheduling Algorithms – Be able to draw Gantt charts for SCAN/C-SCAN. ✅ RAID Levels – Know RAID 0, 1, 5, 10 and their trade-offs. ✅ Device Drivers – Explain their role in hardware-software communication. ✅ Performance Metrics – Calculate throughput and response time in examples.
Common Exam Questions
- "Explain interrupt-driven I/O with a diagram." → Draw a sequence diagram of CPU-device-OS interaction.
- "Compare FCFS and SCAN disk scheduling." → Use a Gantt chart example.
- "What is spooling? How does it help in a multi-user system?" → Relate to printer queues or NTC traffic management.
- "Explain RAID 5 with a diagram." → Show how parity bits work.
- "How does DMA reduce CPU overhead?" → Compare with polling and interrupts.
Final Note: I/O systems are critical in real-world applications—from eSewa payments to Daraz order processing to NTC traffic control. Mastering interrupts, DMA, buffering, disk scheduling, and RAID will help you score full marks and understand how modern systems work efficiently. 🚀
Based on the PU BE Computer (PU) syllabus for Operating System, unit 7.
Discussion
Loading…