───✱*.。:。✱*.:。✧*.。✰*.:。✧*.。:。*.。✱ ───
I/O Communication Methods
- Three main strategies taken by the CPU for handling I/O
- Polled I/O
- Interrupt-Driven I/O
- Direct Memory Access (DMA)
- These strategies vary in efficiency, involvement by the CPU, and complexity
Polled I/O
- The CPU checks (polls) the device status in a loop
- It will continue polling until the device is ready
- Such as waiting for keyboard input
Pros
- Simple to implement
- Predictable timing
Cons
- CPU is busy waiting, which wastes cycles
- Not scalable for fast or numerous devices
Interrupt-Driven I/O
- The CPU executes other tasks until I/O devices send an interrupt
- CPU pauses, handles I/O via an Interrupt Service Routine (ISR) then resumes
Pros
- CPU is freed up to do useful work — no wasted cycles
- More efficient than polling
Cons
- Slight overhead in context switching
- More complex to implement and debug
Direct Memory Access (DMA)
- A dedicated DMA controller moves data between I/O and memory
- The CPU sets up the transfer, then continues other work
- Device signals the CPU only after the entire transfer is complete
Pros
- Very efficient for large data transfers
- CPU remains mostly uninvolved
Cons
- Requires additional hardware (DMA controller)
- Potential memory bus contention
Comparison Table
Feature | Polled I/O | Interrupts | DMA |
---|---|---|---|
CPU Use | High | Moderate | Low |
Efficiency | Low | Moderate+High | High |
Hardware Need | None | Interrupt Controller | DMA Controller |
Good for | Simple/Slow Devices | User input, moderate speed | High-speed, bulk data |
Example | Checking for keyboard key press | Mouse click or disk ready interrupt | Transferring large file from SSD to RAM |
───✱*.。:。✱*.:。✧*.。✰*.:。✧*.。:。*.。✱ ───