Alex Rivera | Logout

What is the purpose of hard disk direct memory access?

Asked 2010-09-15T10:41:59.603
11

At first glance it seems like a good idea to let the hard disk write to RAM on its own, without CPU instructions copying data, particularly with the success of asynchronous networking in mind. But the Wikipedia article on Direct Memory Access (DMA) states this:

With DMA, the CPU gets freed from this overhead and can do useful tasks during data transfer (though the CPU bus would be partly blocked by DMA).

I don't understand how a bus line can be "partly blocked". Presumably memory can be accessed by one device at the time, and it then seems like there is little useful work the CPU can actually do. It would be blocked on the first attempt to read uncached memory, which I expect is very quickly in the case of a 2 mb cache.

The goal of freeing up the CPU to do other tasks seems gratuitous. Does hard disk DMA foster any performance increase in practice?

Edit
Report

2 Answers

4

I don't understand how a bus line can be "partly blocked"

Over a period of many clock cycles, some will be blocked and some will not. Quoting the University of Melbourne:

Q2. What is cycle stealing? Why are there cycles to steal?

A2. When a DMA device transfers data to or from memory, it will (in most architectures) use the same bus as the CPU would use to access memory. If the CPU wants to use the bus at the same time as a DMA device, the CPU will stall for a cycle, since the DMA device has the higher priority. This is necessary to prevent overruns with small DMA buffers. (The CPU never suffers from overruns.)

Most modern CPUs have caches that satisfy most memory references without having to go to main memory through the bus. DMA will therefore have much less impact on them.

Even if the CPU is completely starved while a DMA block transfer is occurring, it will happen faster than if the CPU had to sit in a loop shifting bytes to/from an I/O device.

answered 2010-09-17T23:56:53.377
0

If you're using Linux, you can test this very easily by disabling DMA with hdparm. The effect is dramatic.

answered 2010-09-22T19:11:02.017

Your Answer