Computer Architecture 31 PDF
Computer Architecture 31 PDF
________________________________________________________
Lecture No. 31
Reading Material
Summary
• Direct Memory Access (DMA):
Introduction
Direct Memory Access is a technique which allows a peripheral to read from and/or write
to memory without intervention by the CPU. It is a simple form of bus mastering where
the I/O device is set up by the CPU to transfer one or more contiguous blocks of memory.
After the transfer is complete, the I/O device gives control back to the CPU.
The following DMA transfer combinations are possible:
• Memory to memory
• Memory to peripheral
• Peripheral to memory
• Peripheral to peripheral
The DMA approach is to "turn off" (i.e., tri-state and electrically disconnect from the
system buses) the CPU and let a peripheral device (or memory - another module or
another block of the same module) communicate directly with the memory (or another
peripheral).
ADVANTAGE: Higher transfer rates (approaching that of the memory) can be achieved.
DISADVANTAGE: A DMA Controller, or a DMAC, is needed, making the system
complex and expensive.
Generally, DMA requests have priority over all other bus activities, including interrupts.
No interrupts may be recognized during a DMA cycle.
• load r1,[6]
• out r1, datap
Similar comments apply to the in instruction.
Thus, the real cause of the limited transfer rate is the CPU itself. It acts as an
unnecessary "middleman". The above discussion also implies that, in general, every
data word travels over the system bus twice.
Some Definitions:
DMA Configurations:
• Single Bus Detached DMA
• Single Bus Integrated DMA
• I/O Bus
IO Bus
In this configuration we integrate the
DMA and I/O modules through an I/O
bus. So it will cut the number of I/O
interfaces required between DMA and
I/O module.
Example
An I/O device transfers data at a rate of 10MB/s over a 100MB/s bus. The data is
transferred in 4KB blocks. If the processor operates at 500MHz, and it takes a total of
5000 cycles to handle each DMA request, find the fraction of CPU time handling the data
transfer with and without DMA.
Solution.
Without DMA
The processor here copies the data into memory as it is sent over the bus. Since
the I/O device sends data at a rate of 10MB/s over the 100MB/s bus, 10 % of each second
is spent transferring data. Thus 10% of the CPU time is spent copying data to memory.
With DMA
Time required in handling each DMA request is 5000 cycles. Since 2500 DMA
requests are issued (10MB/4KB) the total time taken is 12,500,000 cycles. As the CPU
clock is 500MHZ, the fraction of CPU time spent is 12,500,000/(500x106) or 2.5%.
Example
A hard drive with a maximum transfer rate of 1Mbyte/sec is connected to a 32-bit,
10MIPS CPU operating at a clock frequency of 100 MHz. Assume that the I/O interface
is DMA based and it takes 500 clock cycles for the CPU to set-up the DMA controller.
Also assume that the interrupt handling process at the end of the DMA transfer takes an
additional 300 CPU clock cycles. If the data transfer is done using 2 KB blocks, calculate
the percentage of the CPU time consumed in handling the hard drive.
Solution
Since the hard drive transfers at 1MB/sec, and each block size is 2KB, there are
Cycle Stealing
The DMA module takes control of the bus to transfer data to and from memory by
forcing the CPU to temporarily suspend its operation. This approach is called Cycle
Stealing because in this approach DMA steals a bus cycle.
I/O processors
When I/O module has its own local
memory to control a large number of I/O
devices without the involvement of CPU is called I/O processor.
I/O Channels
When an I/O module has a capability of executing a specific set of instructions for
specific I/O devices in the memory without the involvement of CPU is called I/O
channel.
Selector Channel
It is the DMA controller that can do
block transfers for several devices but
only one at a time.
Byte Multiplexer
• Byte multiplexer accepts or transmits characters.
• Interleaves bytes from several devices.
• Used for low speed devices.
Block Multiplexer
• Block multiplexer accepts or transmits block of characters.
• Interleaves blocks of bytes from several devices.
• Used for high speed devices.
Virtual Address:
Virtual address is generated be the logical by the memory management unit for
translation.
Physical Address:
Physical address is the address in the memory.