问题描述
我了解到,如果DMA可用,则处理器可以将磁盘块的长读取或写入请求路由到DMA,并专注于其他工作.但是,在此传输过程中,DMA到内存的数据/控制通道很忙.处理器在这段时间内还能做什么?
首先,DMA(本身)几乎已经过时了.如最初定义的那样,DMA控制器依赖于这样的事实,即总线具有单独的行可断言以进行内存读/写和I/O读/写. DMA控制器通过同时声明存储器读取和I/O写入(反之亦然)来利用这一点.然后,DMA控制器在总线上生成连续的地址,并在每个总线周期从内存中读取数据并将其写入输出端口(反之亦然).
但是,PCI总线没有 not 具有用于存储器读/写和I/O读/写的单独行.相反,它为任何给定的事务编码一个(并且只有一个)命令. PCI通常不使用DMA,而是进行总线主控传输.这意味着I/O设备本身代替了在I/O设备和内存之间传输内存的DMA控制器,而直接在内存之间直接传输数据.
关于CPU当时还能做什么,这全都取决于.回到DMA普遍的时代,答案通常是不多",例如,在Windows的早期版本中,读写软盘(确实使用了DMA控制器)在相当长的时间内锁定了系统. /p>
但是,如今,内存的带宽通常比I/O总线大得多,因此,即使外设正在读取或写入内存,通常也留有相当数量的带宽供CPU使用.此外,现代CPU通常具有相当大的缓存,因此它通常可以执行某些指令而完全不使用主内存.
I read that if DMA is available, then processor can route long read or write requests of disk blocks to the DMA and concentrate on other work. But, DMA to memory data/control channel is busy during this transfer. What else can processor do during this time?
First of all, DMA (per se) is almost entirely obsolete. As originally defined, DMA controllers depended on the fact that the bus had separate lines to assert for memory read/write, and I/O read/write. The DMA controller took advantage of that by asserting both a memory read and I/O write (or vice versa) at the same time. The DMA controller then generated successive addresses on the bus, and data was read from memory and written to an output port (or vice versa) each bus cycle.
The PCI bus, however, does not have separate lines for memory read/write and I/O read/write. Instead, it encodes one (and only one) command for any given transaction. Instead of using DMA, PCI normally does bus-mastering transfers. This means instead of a DMA controller that transfers memory between the I/O device and memory, the I/O device itself transfers data directly to or from memory.
As for what else the CPU can do at the time, it all depends. Back when DMA was common, the answer was usually "not much" -- for example, under early versions of Windows, reading or writing a floppy disk (which did use the DMA controller) pretty much locked up the system for the duration.
Nowadays, however, the memory typically has considerably greater bandwidth than the I/O bus, so even while a peripheral is reading or writing memory, there's usually a fair amount of bandwidth left over for the CPU to use. In addition, a modern CPU typically has a fair large cache, so it can often execute some instruction without using main memory at all.
这篇关于直接内存访问DMA-它如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!