进程如何使用unix内核来执行C中的读操作? [英] How does processes intract with unix kernel to perform read operation in C?

查看:88
本文介绍了进程如何使用unix内核来执行C中的读操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在开发一个项目,我的项目需要尽可能多地利用内存。此时我感到困惑。众所周知,系统内存分为用户空间和内核空间。我想知道何时调用read()系统调用或fread()然后内核是否在内核空间中创建缓冲区并将数据提取给它,然后将数据传输到用户空间中的缓冲区,或者直接提供链接到将数据复制到用户空间中的缓冲区。换句话说,我可以说一个副本是完成还是双重复制?



提前致谢。



Vinay Tiwary

Hello, I am working on a project and my project needs to utilize memory as much as possible. I got a confusion at this point. As everyone knows system memory is divided into user space and kernel space. I want to know when I call a read() system call or fread() then whether the kernel creates a buffer in kernel space and fetches the data to it and then transfers data to the buffer in user space or it directly provides a link to copy data to the buffer in user space. In another words, I can say whether a single copy is done or a double copy happens?

Thanks in advance.

Vinay Tiwary

推荐答案

大多数驱动程序从设备读取固定大小的块,然后将请求数据的特定部分传输给用户。在某些情况下,驱动程序需要执行多次读取才能获得文件的正确部分。驱动程序使用内核内存来读取(或写入)设备。
Most drivers read blocks of fixed size from the device and then transfer the specific parts of the requested data to the user. In some cases the driver will need to do multiple reads to get the correct portions of the file. The driver uses kernel memory for the read from (or write to) the device.


这篇关于进程如何使用unix内核来执行C中的读操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆