相关参考链接:
https://blog.youkuaiyun.com/msdnchina/article/details/99205560
在linux命令行中执行man fflush即可。
我的本意是想弄明白fflush()函数是数据的写入目的地是哪里,如下是man fflush结果:
NOTES
Note that fflush() only flushes the user-space buffers provided by the C library. To ensure that the data is physically stored on disk the kernel buffers must be flushed too, for example, with sync(2) or fsync(2).
从上面的描述看,fflush()的目的地是kernel buffers,也就是file system cache,也就是kernel的 page cache。

本文详细解析了fflush()函数的作用及其实现机制,强调该函数仅刷新由C库提供的用户空间缓冲区,并不会直接将数据写入磁盘。要确保数据物理存储于磁盘上,还需使用sync(2)或fsync(2)等函数来刷新内核缓冲区。
1356

被折叠的 条评论
为什么被折叠?



