Difference between fflush and fsync
来源:互联网 发布:安卓上使用数据库 编辑:程序博客网 时间:2024/04/29 14:36
今天做APUE的习题,对fflush和fsync的区别不甚了解,google了一下,找到了一个回答备忘下:
原文链接:http://stackoverflow.com/questions/2340610/difference-between-fflush-and-fsync
fflush()
works on FILE* , it just flushes the internal buffers in the FILE*
of your application out to the OS.
fsync
works on a lower level, it tells the OS to flush its buffers to the physical media.
OSs heavily caches data you write to a file. If the OS enforced every write to hit the drive, things would be very slow. fsync(among other things) allows you to control when the data should hit the drive.
Furthermore, fsync/commit works on a file descriptor. It has no knowledge of a FILE* and can't flush its buffers. FILE* lives in your application, file descriptors lives in the OS kernel, typically.
还有一个链接,写的也很详细:http://blog.chinaunix.net/uid-1911213-id-3412851.html
- Difference between fflush and fsync
- fflush and fsync区别
- The difference between (()) and ().
- difference between "<" and "<<"
- Difference Between typedef and #define
- Difference between PCDATA and CDATA
- Difference between CComPtr and CComQIPtr
- Difference between RVCT and GCCE
- Difference between RVCT and GCCE
- difference between slist and list.
- difference between stack and heap
- Difference between replace and translate
- Difference between PrintWriter and PrintStream
- difference between Cookie and Session
- Difference Between Buffer and Cache
- Difference between Statement and preparedStatement
- Difference between .DLL And .LIB
- difference between VirtualBox and vmware
- Android SDK更新 Connection to http://dl-ssl.google.com refused 解决方法
- Vim 自动补全成对的括号和引号
- codeforces 397B
- Hadoop能做什么
- 数据简单处理
- Difference between fflush and fsync
- 算是继往开来
- linux查看硬件设备信息
- Valid Number
- 二叉排序树、平衡树、红黑树
- usaco training 4.2.3 Job Processing 题解
- EmEditor的两个妙用
- 脉搏波,心率
- Android弹球小游戏