Labs ICT
โญ Pro Login

Direct Memory Access

High-speed data transfer without CPU involvement

Direct Memory Access (DMA)

When you transfer a large file from a hard drive to memory, do you want the CPU to handle every single byte? Of course not! DMA allows I/O devices to transfer data directly to/from memory without CPU intervention.

How DMA Works


    DMA Transfer Process
    +---------------------------------------------+
    |                                             |
    |  Step 1: CPU sets up DMA transfer         |
    |  +--------------------------------------+  |
    |  | - Source address (I/O device)        |  |
    |  | - Destination address (memory)      |  |
    |  | - Transfer size                     |  |
    |  | - Transfer direction                |  |
    |  +--------------------------------------+  |
    |                    |                       |
    |                    v                       |
    |  Step 2: DMA Controller takes over        |
    |  +--------------------------------------+  |
    |  | I/O Device <--> DMA <--> Memory     |  |
    |  | (CPU is free to do other work!)     |  |
    |  +--------------------------------------+  |
    |                    |                       |
    |                    v                       |
    |  Step 3: DMA signals completion          |
    |  +--------------------------------------+  |
    |  | DMA sends interrupt to CPU          |  |
    |  | CPU acknowledges transfer complete  |  |
    |  +--------------------------------------+  |
    +---------------------------------------------+

DMA Components

  • DMA Controller: Specialized hardware that manages the transfer
  • DMA Channels: Independent paths for simultaneous transfers
  • Bus Arbitration: Decides who gets to use the system bus

DMA Transfer Modes


    DMA Transfer Modes
    +---------------------------------------------+
    |                                             |
    |  1. Burst Mode:                             |
    |     DMA takes bus, transfers all data,     |
    |     then releases bus                      |
    |     [======BURST TRANSFER======]           |
    |                                             |
    |  2. Cycle Steal:                            |
    |     DMA takes bus for one cycle,           |
    |     transfers one word, releases bus       |
    |     [W][W][W][W][W][W][W][W][W][W]        |
    |                                             |
    |  3. Transparent DMA:                        |
    |     DMA uses bus only when CPU isn't       |
    |     using it (transparent to CPU)          |
    |     [W]   [W]   [W]   [W]   [W]           |
    +---------------------------------------------+

Benefits of DMA

  • CPU Efficiency: CPU can work on other tasks during transfers
  • Higher Throughput: DMA can transfer data faster than CPU byte-by-byte
  • Lower Latency: Direct path reduces transfer time

DMA is essential for high-speed devices like SSDs, network cards, and graphics cards that need to transfer large amounts of data quickly.

๐Ÿงช Quick Quiz

What is the purpose of DMA (Direct Memory Access)?