COA Notes
DMA controller, DMA transfer modes, cycle stealing, and burst transfer mechanisms.
Introduction
Even interrupt-driven I/O has a problem: for large data transfers (loading a file, streaming video, network packets), the CPU must handle EVERY word — read from device, write to memory, one word at a time. For a 1 GB file transfer, that's billions of CPU interventions! DMA (Direct Memory Access) solves this by providing a specialized hardware controller that transfers data directly between device and memory WITHOUT CPU involvement. The CPU sets up the transfer and then is free to do other work.
The DMA Concept
Instead of: Device → CPU → Memory (CPU involved in every transfer) DMA does: Device → DMA Controller → Memory (CPU only involved in setup)
Without DMA
CPU: Setup → Read Device → Write Memory → Read Device → Write Memory → ... → Done
(CPU busy for entire transfer)
With DMA
CPU: Setup DMA → [FREE TO DO OTHER WORK] → Interrupt: "Transfer complete!"
DMA: Transfer → Transfer → Transfer → Transfer → Done!
DMA Controller Architecture
| Start Address Reg | Word Count Reg | |||
|---|---|---|---|---|
| (memory address) | (bytes remaining) | |||
| Control Register | Status Register | |||
| (direction, mode) | (done, error) |
DMA Transfer Steps
- CPU programs the DMA controller:
- Starting memory address (where to put/get data)
- Transfer count (how many bytes/words)
- Transfer direction (device→memory or memory→device)
- Transfer mode (burst, cycle-stealing, etc.)
- CPU tells device to start (or device requests transfer)
- DMA controller takes over:
- Requests the bus (Bus Request signal)
- CPU grants bus access (Bus Grant signal)
- DMA controller drives address and data buses
- Transfers data directly between device and memory
- Increments address, decrements count each transfer
- Transfer complete:
- DMA controller releases the bus
- Asserts interrupt to notify CPU "done!"
- CPU reads status register if needed
DMA Transfer Modes
Burst Mode (Block Transfer)
- DMA holds the bus for the ENTIRE transfer
- Fastest for the transfer itself
- CPU is completely locked out until done
- Best for: time-critical transfers where latency matters
Cycle Stealing Mode
- DMA takes the bus for ONE word, then releases
- CPU and DMA alternate bus access word-by-word
- CPU slows down slightly but isn't blocked
- Best for: transfers that don't need to complete quickly
Transparent Mode
- DMA transfers only when CPU isn't using the bus
- Zero impact on CPU performance
- Slowest overall transfer time
- Best for: background transfers where speed doesn't matter
Comparison of I/O Methods
| Feature | Programmed I/O | Interrupt I/O | DMA |
|---|---|---|---|
| CPU involvement | Every byte | Every byte (via ISR) | Setup + completion only |
| CPU utilization | 0% (busy-wait) | ~90% | ~99% |
| Transfer speed | CPU-limited | CPU-limited | Bus-limited (faster) |
| Hardware cost | Minimal | Interrupt controller | DMA controller |
| Best for | Simple, fast devices | Infrequent events | Bulk data transfers |
| Example use | Sensor read | Keyboard input | Disk/network transfers |
Bus Arbitration for DMA
Since both CPU and DMA need the bus, arbitration is required:
- Bus Request (BR): DMA asks for bus control
- Bus Grant (BG): CPU/arbiter allows DMA to use bus
- Bus Busy (BB): Indicates bus is currently in use
The DMA controller becomes a bus master during its transfers.
Key Takeaways
- DMA transfers data between device and memory WITHOUT CPU involvement
- CPU programs DMA (address, count, direction), then is free to do other work
- DMA controller takes over the bus and handles the entire transfer
- Three modes: Burst (fastest, blocks CPU), Cycle-stealing (shares bus), Transparent (no impact)
- After transfer completes, DMA interrupts the CPU to signal completion
- DMA is essential for high-bandwidth devices (disk, network, GPU)
- DMA reduces CPU overhead from O(n) per byte to O(1) per transfer
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Direct Memory Access (DMA).
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Computer Organization & Architecture topic.
Search Terms
computer-organization, computer organization & architecture, computer, organization, input, output, dma, direct memory access (dma)
Related Computer Organization & Architecture Topics