fread 需要处理能力/与 DMA 一起使用吗?
fread 需要处理能力/与 DMA 一起使用吗?
假设文件所在的设备支持 DMA?
does fread takes processing power / works with DMA ?
Assume that device on which file is residing has DMA support ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,确实如此。但当你在Linux中使用“time”命令时,它会显示为“系统”时间。
基本上,您进行系统调用,告诉操作系统要读取哪些数据以及将其放在哪里,然后操作系统(这里是 CPU 周期)设置缓冲区并告诉 DMA 将数据放在哪里。您的进程被阻止,操作系统会选择一个新进程来运行,但这并不真正影响您的 fread 调用。最终,读取完成,DMA 系统向处理器发出中断(更多 CPU 周期即将到来),此时操作系统会看到哪些数据已准备好返回到您的程序(并将您的线程放入就绪队列 - 结束) CPU 时间)。
Yes it does. But it will show up as "system" time when you use the "time" command in Linux.
Basically, you make a system call, telling the OS what data to read and where to put it, then the OS (here comes the CPU cycles) sets up the buffers and tells the DMA where to put the data. Your process is blocked, and the OS picks a new process to run, but that's not really counting against your fread call. Eventually, the reading completes, and the DMA system issues an interrupt to the processor (more CPU cycles coming up) at which point the OS sees what data is ready returns to your program (and puts your thread on ready queue -- end of the CPU time).
使用 DMA 还是 nt 与您用来读取文件的 C 库调用无关。通常,如果没有管理员权限,您无论如何都无法影响它。
编辑:
系统是否使用 DMA 访问设备并不取决于您是否使用 scanf、fread、read 或任何其他文件访问函数。它取决于设备驱动程序设置,普通用户无法更改。
就与设备通信所花费的时间而言,几乎所有时间都会被进程的系统计时器计算在内(如上面的答案所述),而一小部分根本不会被计算在内。
Whether DMA is used or nt is independent of which C library call you use to read from a file. Usually you can't influence it anyhow without admin privileges.
EDIT:
Whether system uses DMA to access a device does not depend on whether you use scanf, fread, read or any other file access function. It depends on device driver settings, which a normal user can't change.
As far as time spent communicating with the device is concerned, nearly all of it will be counted by your process's system timer (as the answer above stated) and a small part won't be counted at all.