fread 需要处理能力/与 DMA 一起使用吗?

发布于 2024-08-12 13:24:46 字数 57 浏览 4 评论 0原文

fread 需要处理能力/与 DMA 一起使用吗?

假设文件所在的设备支持 DMA?

does fread takes processing power / works with DMA ?

Assume that device on which file is residing has DMA support ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

久而酒知 2024-08-19 13:24:46

是的,确实如此。但当你在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).

小伙你站住 2024-08-19 13:24:46

使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文