Input/Output (I/O) Organization

In a computer system, the CPU needs to communicate with various peripheral devices (like keyboards, disks, and monitors). Because these devices operate at different speeds than the CPU, specific I/O techniques are used to manage data transfer efficiently.

1. Programmed I/O

In this method, the CPU is responsible for checking the status of the I/O device constantly (polling) until it is ready for data transfer. This keeps the CPU busy and wastes processing power.

  • CPU stays in a loop until the device is ready.
  • Simple to implement but highly inefficient.
  • Best for very simple, dedicated systems.

2. Interrupt-Initiated I/O

Instead of the CPU waiting, the device 'interrupts' the CPU when it is ready. This allows the CPU to perform other tasks in the meantime.

  • CPU issues a command and moves to other work.
  • Device sends a hardware signal (Interrupt) when ready.
  • CPU saves its current state and executes an Interrupt Service Routine (ISR).

3. Direct Memory Access (DMA)

For high-speed data transfer (like disk to RAM), using the CPU as a middleman is too slow. DMA allows the I/O device to transfer data directly to or from memory without CPU intervention.

  • A specialized hardware called a **DMA Controller** manages the transfer.
  • The CPU is only involved at the start and end of the transfer.
  • Significantly improves system throughput for large data blocks.

Comparison Table

FeatureProgrammed I/OInterrupt-InitiatedDMA
CPU InvolvementContinuous (Polling)Minimal (Only for ISR)Negligible (Only init/end)
Data SpeedSlowModerateVery Fast
Hardware CostZero/LowModerateHigh (Needs Controller)
EfficiencyVery LowHighHighest

DMA Transfer Modes

  • **Burst Mode:** Entire block of data is transferred in one go; CPU is blocked.
  • **Cycle Stealing:** DMA transfers one word at a time, 'stealing' a bus cycle from the CPU.
  • **Transparent Mode:** DMA only uses the bus when the CPU is not using it.

Advanced Concepts

  • I/O Processors (IOP)
  • Vectored vs. Non-Vectored Interrupts
  • Priority Interrupt Controller (PIC)
  • Daisy Chaining
  • Bus Arbitration

Common Mistakes to Avoid

  • Thinking DMA removes the need for a CPU (CPU still initializes the transfer).
  • Confusing an 'Interrupt' with a 'System Call'.
  • Assuming DMA is used for every device (too expensive for a mouse/keyboard).
  • Ignoring the overhead of Context Switching during interrupts.

Practice Exercises

  • Explain the steps involved in a DMA transfer.
  • Why is polling unsuitable for a multitasking operating system?
  • What is a 'Bus Master' and how does the DMA controller become one?
  • Differentiate between Memory-Mapped I/O and Isolated I/O.

Conclusion

Choosing the right I/O method depends on the device speed and system requirements. While Interrupts handle slow-to-medium speed devices efficiently, DMA is essential for the high-bandwidth requirements of modern storage and networking.

Note: Note: In modern systems, DMA is the primary method for disk, GPU, and network card communication.