I/O Transfer Modes

Understanding CPU-Peripheral Data Transfer Methods

📊 Transfer Modes Overview

Transfer modes define how the CPU coordinates with peripheral devices to move data into or out of memory and registers. Each mode represents a different approach to handling the speed mismatch between fast CPUs and slower I/O devices.

Mode CPU Involvement Efficiency Best For
Programmed I/O Continuous monitoring Low ⭐ Simple, infrequent transfers
Interrupt I/O On-demand response Medium ⭐⭐ Moderate transfer rates
Direct Memory Access Minimal (initial setup) High ⭐⭐⭐ High-speed bulk transfers
🎯 Synchronization

All modes use flags to coordinate between fast CPUs and slow peripherals

⚡ Performance

Efficiency increases from PIO → Interrupt → DMA

🔧 Complexity

Hardware and software complexity grows with efficiency gains

⚙️ Programmed I/O (PIO)

In Programmed I/O, the CPU is solely responsible for initiating and overseeing the entire data transfer operation. The CPU must constantly check the status of the I/O device before every data transfer.

Programmed IO
🧠 CPU (Central Processing Unit)

The CPU checks the status register flag to detect data availability, reads the data from the interface data register, and clears the flag to allow the next transfer.

🔌 I/O Interface (Module)

The interface acts as a mediator, storing incoming data in the data register, setting the status flag, and coordinating handshake signals like data valid and data accepted.

🖨️ I/O Device

The I/O device generates data and places it on the I/O bus, activates the data valid signal, and waits for acknowledgment before sending the next byte.

PIO Flowchart - Input Operation
Programmed IO Flowchart
LOOP: READ status_register
      IF (flag == 1) THEN
           READ data_register
           STORE data in memory
           CLEAR flag
      ELSE
           BUN EXIT
      BUN LOOP
EXIT: ; Continue with processing...
⚠️ Main Drawback: The CPU is much faster than I/O devices. Constantly checking flags in a loop wastes valuable processing time that could be used for other computations. This is highly inefficient!

⚡ Interrupt-Initiated I/O

Interrupt I/O is an enhanced transfer mode designed to overcome PIO's efficiency problems by allowing the CPU to perform other tasks while waiting for slow I/O operations to complete.

🔔 CPU (Central Processing Unit)

The CPU executes programs without monitoring flags, deviating only when an interrupt occurs. It responds by saving the return address to a memory stack and branching to an I/O service routine.

🔌 Interface

The interface informs the computer when it is ready for data transfer by setting a flag bit. This action triggers the interrupt facility, signaling the processor to pause its current program.

⚙️ Service Routine

This routine processes the required I/O transfer after the CPU identifies the branch address. Once finished, control returns to the original program using the return address stored previously in the stack.

Methods of Service Routine

🎯 Vectored Interrupt

The interrupting source provides the computer with specific branch information known as the interrupt vector, which identifies the first address or a pointer to the service routine.


⚡ Non-vectored Interrupt

The branch address for the service routine is assigned to a predetermined, fixed location in memory, rather than being supplied by the interrupting device.

✅ Key Advantage: The CPU can perform useful work while waiting for I/O. The device notifies the CPU only when ready, eliminating wasteful busy-waiting!

🚀 Direct Memory Access (DMA)

DMA is the most efficient transfer mode for high-speed devices. It allows peripherals to transfer data directly to/from memory without continuous CPU involvement.

🎯 DMA Controller

Specialized hardware that manages data transfers independently of the CPU

🚌 Bus Control

DMA controller temporarily takes over system bus to transfer data directly

⚡ High Speed

Ideal for disk drives, graphics cards, and network interfaces requiring bulk transfers

DMA Transfer Process
CPU initializes DMA controller
↓
Set memory address, word count,
transfer direction (Read/Write)
↓
CPU continues other work
↓
Device ready to transfer
↓
DMA controller requests bus
CPU relinquishes bus control
↓
DMA transfers data:
Device ↔ Memory (direct!)
↓
Update address, decrement count
Repeat until count = 0
↓
DMA sends interrupt to CPU:
"Transfer complete!"
↓
CPU resumes full control

DMA Registers

Address Register

Holds current memory address for transfer

Word Count Register

Number of words remaining to transfer

Control Register

Specifies transfer mode and direction

💡 Maximum Efficiency: CPU is only involved in initial setup and receiving completion notification. The entire transfer happens without CPU intervention, making DMA perfect for high-bandwidth operations!