CPU,内存, 硬盘,指令之间的关系

For a disk read the data flow is essentially:
  • after the read/write assembly is at the requested cylinder, the requested r/w head is selected.

  • at each sector, the sector ID is read. If the sector number that was read matches the requested sector number, then the sector data is read.

  • the sector data is read as a serial bit stream, and converted to bytes.

  • the bytes of the sector are stored in a sector buffer (usually SRAM in the controller); this sector buffer is distinct from the “disk cache”.

  • once the entire sector has been read, the data is validated using ECC, and perhaps corrected.

  • once validated, the sector data is transferred from the controller to the host PC. Note: existence of this sector buffer is not well known, and there is widespread misinformation that the transfer speed on the host (e.g.ATA) interface is tied or limited by the bit rate at the R/W head. That is completely false, since these two data transfers are independent and sequential operations and not concurrent.

  • as the PC receives the data from the disk controller through the ATA interface, the PC can use either programmed I/O (the CPU repeatedly reads the ATA port’s data register and copies the value to the destination memory) or DMA (the DMA controller is setup to copy N bytes from the ATA port’s data register to a memory buffer w/o further CPU intervention).

  • the PC’s memory “buffer” that receives the data could be the application’s buffer (when using block I/O system call), or could be an internal system buffer under filesystem control, or even program or data memory if the data came from the swap area (or page file).

A write to disk is similar, except that the data is transferred from PC to disk controller, the ECC is calculated, the requested sector is located, and then the data is written from the sector buffer to the platter.

For extra credit:

Read up on “scatter-gather” transfers, which uses DMA chaining and a scatter-gather list of memory addresses and buffer lengths. Instead of one large, contiguous memory buffer, a “scatter-gather” transfer allows the use of non-contiguous memory buffers to be aggregated for the disk I/O request.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值