Reputation: 14664
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?).
Upvotes: 0
Views: 1520
Reputation: 53699
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.
Upvotes: 3
Reputation: 86504
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.
Upvotes: 0
Reputation: 3347
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.
Upvotes: 2