ArticleslgStudy

computer science

Direct memory access

Direct memory access is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Direct memory access rather than just read about it. In short: Direct memory access (DMA) is a feature of many computer systems that allows certain hardware subsystems to access main system memory independently of the central processing unit (CPU). Without DMA, programmed input–output must be used to transfer data which typically fully occupies the CPU for the entire duration of the transfer, and is thus unavailable to perform other work.

Direct memory access — main illustration
Direct memory access — illustration

Key takeaways

  • Direct memory access belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Direct memory access to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Direct memory access from memory before moving on to harder problems.

Reference excerpt

Direct memory access (DMA) is a feature of many computer systems that allows certain hardware subsystems to access main system memory independently of the central processing unit (CPU). Without DMA, programmed input–output must be used to transfer data which typically fully occupies the CPU for the entire duration of the transfer, and is thus unavailable to perform other work. With DMA, the CPU first initiates the transfer, then it does other operations while the transfer is in progress, and it finally receives an interrupt from the direct memory access controller (DMAC) when the operation is done. This feature is useful at any time that the CPU cannot keep up with the rate of data transfer, or when the CPU needs to perform work while waiting for a relatively slow data transfer. Many hardware systems use DMA, including disk drive controllers, graphics cards, network cards, sound cards and dedicated DMA controllers (acting on behalf of the aforementioned device types). DMA is also used for intra-chip data transfer in some multi-core processors. Computers that have DMA capability can transfer data to and from devices with much less CPU overhead than computers without DMA. DMA can also be used for memory-to-memory transfers. DMA can offload expensive memory operations, such as large copies or scatter-gather operations, from the CPU to a DMA controller. An implementation example is the I/O Acceleration Technology. DMA is of interest in network-on-chip and in-memory computing architectures. While hardware acceleration is usually vendor-specific, direct memory access can be used by the class driver.

Principles

Third-party

Standard DMA, also called third-party DMA, uses a DMA controller. A DMA controller can generate memory addresses and initiate memory read or write cycles. It contains several hardware registers that can be written and read by the CPU. These include a memory address register, a count register, and one or more control registers. Depending on what features the DMA controller provides, these control registers might specify some combination of the source, the destination, the direction of the transfer (reading from the I/O device or writing to the I/O device). To carry out an input, output or memory-to-memory operation, the host processor initializes the DMA controller with a count of the number of words to transfer, and the memory address to use. The CPU then commands the peripheral device to initiate a data transfer. The DMA controller then provides addresses and read/write control lines to the system memory. Each time a byte of data is ready to be transferred between the peripheral device and memory, the DMA controller increments its internal address register until the full block of data is transferred.

Bus mastering In a bus mastering system, also known as a first-party DMA system, the CPU and peripherals can each be granted control of the memory bus. Where a peripheral can become a bus master, it can directly write to system memory without the involvement of the CPU, providing memory address and control signals as required. Some measures must be provided to put the processor into a hold condition so that bus contention does not occur. The peripheral itself may have hardware registers, such as address and count registers, to control the DMA operation.

Modes of operation

Burst mode In burst mode, an entire block of data is transferred in one contiguous sequence. Once the DMA controller is granted access to the system bus by the CPU, it transfers all bytes of data in the data block before releasing control of the system bus back to the CPU. This renders the CPU inactive for relatively long periods of time. The mode is also called block transfer mode.

Cycle stealing mode The cycle stealing mode is used in systems in which the CPU should not be disabled for the length of time needed for burst transfer modes. In the cycle stealing mode, the DMA controller obtains access to the system bus the same way as in burst mode, using BR (Bus Request) and BG (Bus Grant) signals, which are the two signals controlling the interface between the CPU and the DMA controller. However, in cycle-stealing mode, after one unit of data transfer, the control of the system bus is deasserted to the CPU via BG. It is then continually requested again via BR, transferring one unit of data per request, until the entire block of data has been transferred. By continually obtaining and releasing the control of the system bus, the DMA controller essentially interleaves data transfers with CPU activity. The CPU processes an instruction, then the DMA controller transfers one data value, and so on. Data is not transferred as quickly, but the CPU is not idled for as long as in burst mode.

Transparent mode Transparent mode (also called Hidden DMA data transfer mode) is the most efficient mode in terms of overall system performance. In transparent mode, the DMA controller transfers data only when the CPU is performing operations that do not use the system buses. The primary advantage of transparent mode is that the CPU never stops executing its programs, while the disadvantages are that DMA transfers are not prioritized and the hardware needs to predict when the CPU does not intend to use the system buses.

Cache coherency

… excerpt ends here. Continue reading the full article.

Illustrations

Direct memory access illustration

Worked examples

Example 1 — a first encounter with Direct memory access

Start with the simplest possible case. Write down what Direct memory access claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Direct memory access before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Direct memory access ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Direct memory access

In research
Direct memory access appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Direct memory access in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Direct memory access is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer memory, Computer storage buses, Hardware acceleration, so understanding it makes those chapters shorter.
In everyday life
Look for Direct memory access outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Direct memory access” →

How to study Direct memory access in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Direct memory access means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Direct memory access out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Direct memory access in simple terms?

Direct memory access (DMA) is a feature of many computer systems that allows certain hardware subsystems to access main system memory independently of the central processing unit (CPU). Without DMA, programmed input–output must be used to transfer data which typically fully occupies the CPU for the…

Why does Direct memory access matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Direct memory access?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Direct memory access.

Tags

  • Computer memory
  • Computer storage buses
  • Hardware acceleration
  • Input/output
  • Motherboard

Keep exploring