When is the file loaded into memory - for fread, fopen and fwrite calls?(文件何时加载到内存中 - 用于 fread、fopen 和 fwrite 调用?)
问题描述
当我执行 fopen 然后 fread 时,文件实际/部分加载到内存中的时间在 fopen 或 fread 期间?
When I do a fopen and then a fread, when is the file actually/partially loaded in the memory during fopen or fread?
或者是根据文件大小在 fopen 部分加载,然后在时间完全加载害怕吗?
Or is it partially loaded at fopen based on size of file and then fully loaded at time of fread?
同样,当调用 fwrite 时,在操作系统级别内部会发生什么?文件当时是否加载到内存中,或者页面交换发生在仅检索该部分内存中的文件?
Similarly what happens internally at the OS level when fwrite is called? Is the file loaded into memory at that time, or a page swap happens retriving just that part of file in memory?
在每个调用中,在内存中加载文件时,操作系统级别会发生什么情况?
What happens at the OS level at each of these calls with respect to file loading in memory?
推荐答案
fopen()
只创建文件句柄.fread()
实际上将文件读入内存缓冲区(操作系统级别的缓冲可能对客户端透明.)fwrite()
将数据写入文件,但提交到存储可能会延迟(例如,使用日志文件系统.)fopen()
only creates a handle to the file.fread()
actually reads the file into a memory buffer (OS-level buffering may occur transparently to the client.)fwrite()
writes data into the file, though its committing to the storage may get delayed (e.g. with journalled filesystem.)
这篇关于文件何时加载到内存中 - 用于 fread、fopen 和 fwrite 调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:文件何时加载到内存中 - 用于 fread、fopen 和 fwrite 调用?


基础教程推荐
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 常量变量在标题中不起作用 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09