磁盘控制器如何向处理器发出读/写请求已完成的信号
假设一个进程请求向内核读取一个块,操作系统通过直接映射内存向磁盘发出请求(不确定这是否正确),最终由磁盘控制器读取并完成读取请求,磁盘如何向该进程发送信号处理器表明读取请求已完成?它使用相同的直接映射内存吗? (这样的话,是不是就不需要轮询了,效率低下?)。
Assuming a process requested to read a block to kernel and OS issued the request to the disk through direct-mapped memory(Not sure if this is correct), which is eventually read by disk controller and completes the read request, how does disk signal the processor that read request is completed? Does it use the same direct mapped memory? (In this case, isn't polling required, which is inefficient?).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在非常高的级别上,磁盘 IO 在磁盘控制器和 DMA(直接内存访问)控制器之间异步处理。一旦数据传输完成,就会产生中断,表示操作已完成。
At a very high level the Disk IO is handled asyncronously between the Disk Controller and the DMA (Direct Memory Access) controller. Once the data transfer is complete an interupt is raised which signals the completion of the operation.
在 x86 上,您的标签会建议正确的答案。内存映射 I/O 意味着对物理内存中某些位置的写入会被重定向到磁盘的控制寄存器中。当读取准备好时,第一个字被写入数据寄存器,一旦收到硬件中断通知,操作系统就可以通过相同的方法访问该数据寄存器。然后,操作系统将一次读取一个字,将其写入到最终需要的缓冲区中。在汇编级别,这看起来就像一系列内存到内存的移动操作,北桥透明地处理内存映射的细节。
不过,就 DMA 而言,南桥上有一个 DMA 控制器(我认为)充当中介。 CPU 中的操作系统对 DMA 控制器进行编程以进行必要的读取,包括在主存储器中为其提供一个真实的缓冲区(即,未将存储器映射到设备控制器中)。然后,DMA 控制器进行逐字复制,并且仅在所有数据复制到主内存后才抛出磁盘中断。
On the x86, your tags suggest the correct answer. Memory-mapped I/O means that writes to some locations in physical memory get redirected into the control registers for the disk. When the read is ready, the first word is written into the data register, which the OS can access by the same method once notified by a hardware interrupt. The OS will then fetch the read one word at a time, writing it into whatever final buffer needs it. At the assembly level, this looks just like a series of memory-to-memory move operations, with the north bridge handling the details of the memory-mapping transparently.
In the case of DMA, though, there is a DMA controller on the south bridge (I think) which acts as an intermediary. The OS in the CPU programs the DMA controller for the necessary read, including giving it a real buffer in main memory (i.e., not memory-mapped into the device controller). The DMA controller then does the word-by-word copying and only throws the disk interrupt after all the data has been copied into main memory.
控制器通常会触发中断来表示操作已完成。特别是在现代计算机和磁盘控制器中,它们使用 DMA 将数据传输到 RAM,然后触发中断,使 CPU 几乎不需要做任何事情。
The controller usually fires an interrupt to signal that the operation is done. Particularly in modern computers and disk controllers, which use DMA to transfer the data to RAM and then fire the interrupt, leaving the CPU with very little to have to do.