Open In App

Direct Memory Access

Last Updated : 06 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

DMA (Direct memory access) is the special feature within the computer system that transfers the data between memory and peripheral devices(like hard drives) without the intervention of the CPU. In other words, for large data transfer like disk drives, it will be wasteful to use expensive general-purpose processors in which status bits are to be watched and fed the data into the controller register one byte at a time which is termed Programmed I/O. Computers avoid burdening the CPU so, they shift the work to a Direct Memory Access controller. Let’s see the workings of this in detail.

To initiate the DMA transfer the host writes a DMA command block into the memory. This block contains the pointer to the source of the transfer, the pointer to the destination of the transfer, and the count of the number of bytes to be transferred. This command block can be more complex which includes the list of sources and destination addresses that are not contiguous. CPU writes the address of this command block and goes to other work. DMA controller proceeds to operate the memory bus directly, placing the address on it without the intervention of the main CPU. Nowadays simple DMA controller is a standard component in all modern computers.

Block Diagram of DMA

DMA

Block Diagram of DMA

The mutual understanding between the device controller and DMA controller is performed via pair of wires called DMA request and DMA acknowledge. Let’s see what is the role of these wires in the DMA transfer,

Working of DMA Transfer

The device controller places a signal on the DMA request wire when a word of data is available for transfer. This cause DMA controller to seize the memory bus of CPU and place the desired address on the DMA acknowledge wire. Up on successful data transfer the device controller receives the DMA acknowledge and then it removes the DMA request signal.

When the entire transfer is finished, DMA controller interrupts the CPU. This entire process is depicted in the above diagram. DMA controller seizes the memory bus and CPU momentarily prevented from accessing main memory. Although it can access the data items in its cache. This cycle stealing (Seizing the memory bus temporarily and preventing the CPU from accessing it) slows down the CPU computation, shifting the data transfer to DMA controller generally improves the total system performance. Some of the computer architecture used physical memory address for DMA, but other uses virtual addresses (DVMA). Direct virtual memory access performs data transfer between memory mapped I/O without the use of main memory.

FAQs on DMA(Direct Memory Access) in OS

Q.1: what are the advantages of DMA?

Answer:

  1. Speed: The data transfers are faster than the CPU-managed data transfers because it doesn’t require CPU involvement in each byte.
  2. Efficiency: Its reduces the CPU overhead, by allowing it to focus on other tasks.
  3. parallelism: Multiple DMA channels works simultaneously which improves the system performance in terms of throughput.
  4. Reduced Latency: System can become more responsive by DMA transfers because it allows CPU to focus on other tasks.

Q.2: State some of the disadvantages of DMA?

Answer:

  1. compatibility issues: DMA configurations may not always be compatible across different hardware systems.
  2. complexity: The complexity increase as we are writing the DMA command block into the memory which contain all the sources and destinations of data transfer that are not contiguous.
  3. Limited control: As DMA takes control over the memory bus for data transfers which is not always acceptable because in some situations CPU has to wait for the DMA controller to complete the task.
  4. Resource conflicts: In some of DMA capable devices there can be memory conflict when multiple devices attempts to use DMA simultaneously.

Q.3: What is the difference between DMA and DVMA?

Answer:

DMA: It is a feature used to transfer the large set of data between the memory and peripheral devices such as hard drive, network drive… without the involvement of CPU in other way it reduces the load on CPU and increase the performance of the system.

DVMA: It is a feature in which memory transfer is done by using virtual addresses( internally which are translated into physical address). It extends the concept of DMA to the address spaces that involve the memory mapped I/O in virtual memory system.

Q.4: Name some of the use-cases where DMA is used?

Answer:

DMA is beneficial in some of the areas like audio processing , video processing and Disk I/O.

Q.5: Is DMA a processor?

Answer:

No, DMA is not a processor it is a special feature in computer system which allows the peripheral devices to transfer the data directly to and from the memory without the intervention of CPU.

Q.6: What are the modes of transfer in DMA?

Answer:

There are three modes of transfer in DMA,

1.Burst Mode (In this mode the DMA controller takes the control over the memory and releases it after the completion of data transfer )

2.cycle stealing Mode (In this mode the DMA controller force the processor to stop the operation and leave the control over the bus for some short period of time)

3.Transparent Mode (In this mode the DMA controller takes only the system bus if the processor does require it actually)


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads