2

This video mentions the following:

enter image description here

What does it mean for the DMA controller to be granted the data bus control, does that mean the CPU cannot use the bus to access memory and IO devices until the DMA controller re-grants the data bus control to the CPU?

8

Yes. The DMA controller takes ownership of the bus for the duration of the transfer.

That said, I feel obliged to point out that at least on PC-based machines, DMA controllers have been almost entirely obsolete for quite a while now.

On a reasonably modern machine, the DMA controller is used only for I/O to/from floppy disks (and only "directly" connected floppy disks--a floppy that connects via USB doesn't count).

There was also a short time that DMA controllers were used for hard drive transfers, but that was a long time ago (PC-XT) and became obsolete only slightly more recently (PC/AT).

In addition, the DMA controller(s) in a PC depend on specific characteristics of the original ISA bus. To do a DMA transfer, the DMA controller told the bus that it was doing both a memory write and an I/O read (or vice versa) simultaneously. This read data onto the bus, and wrote data to memory (or, again, vice versa) in a single bus cycle.

However, the PCI bus (and PCIe) doesn't have separate lines to be able to simultaneously assert that it's doing an I/O read and a memory write. In any given bus cycle, it can only do one of these types of transactions.

So, when the PCI bus came into use, DMA went from obsolete to downright...well, I can't think of a better term, but became an even worse prospect. Modern computers include a fair amount of jumping through hoops to allow DMA controllers to still work, just in case you decide to use a non-USB floppy disk, but the reality is that nowadays, most machines are probably bought, used, and thrown away, without ever (even once) actually using the DMA controllers.

On a reasonably modern machine, the closest analog of DMA that actually gets used enough to notice is bus mastering controllers. A bus mastering controller works vaguely similarly to a DMA controller. The difference is that instead of having one DMA controller for all peripherals, each peripheral has its own specialized controller that can get control of the bus, do a transfer (e.g., directly to/from the machine's main memory) and then give up its control of the bus. This has a number of obvious advantages--primary among them that it actually works with PCI and PCIe. I suppose I should add: with the advent of PCIe, even that's not really accurate anymore either. PCI was a bus, but PCIe isn't. Instead, it uses a switch fabric, so (among other things) if A wants to talk to B, and C wants to talk to D, those transactions can happen simultaneously, whereas on a bus only one transaction would have been allowed at a time.

Anyway, DMA is almost entirely a historical artifact. If you want to learn more about DMA-like processes that's relevant to a current computer, you probably want to study bus mastering.

  • "Yes. The DMA controller takes ownership of the bus for the duration of the transfer" Does that mean the CPU cannot use the bus to access memory and IO devices while the DMA controller have ownership of the bus? If yes, then does the CPU not do anything in this time, or does it execute the instructions that do not access memory and IO devices? – Christopher Oct 5 '17 at 2:14
  • @Christopher: From Direct Memory Access on Wikipedia: "Without DMA, when the CPU is using programmed input/output, it is typically fully occupied for the entire duration of the read or write operation, 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 DMA controller when the operation is done." – Robert Harvey Oct 5 '17 at 2:16
  • @Robert Harvey "it does other operations while the transfer is in progress" These other things can be to execute any instruction, even if the instruction accesses memory and IO devices? – Christopher Oct 5 '17 at 2:22
  • Except for any operation that might interfere with the DMA bus during a data transfer. You should really read that Wikipedia article. – Robert Harvey Oct 5 '17 at 2:36
  • @Christopher: Yes, the CPU can continue to do other things while the transfer takes place. Due to the low speed of a floppy drive, the bus is also typically idle quite a bit of the time between initiating and completing the transfer. Back in the day, lots of OS/2 fans (among others) made much of the fact that they could still do useful work while formatting a floppy disk, where DOS-based systems nearly ground to a halt while formatting a floppy (because they used the BIOS, which wasn't designed for this sort of task). – Jerry Coffin Oct 5 '17 at 5:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.