zoukankan      html  css  js  c++  java
  • fflush和fsync的联系和区别

    1.出处

    fflush是libc.a中提供的方法,

    fsync是系统提供的系统调用。

    2.原形

    fflush接受一个参数FILE *.

    fflush(FILE *);

    fsync接受的时一个Int型的文件描述符。

    fsync(int fd);

    3.功能

    fflush:是把C库中的缓冲调用write函数写到磁盘[其实是写到内核的缓冲区]。

    fsync:是把内核缓冲刷到磁盘上。

    c库缓冲-----fflush---------〉内核缓冲--------fsync-----〉磁盘

     
    另外关于内核缓冲,标准库缓冲和用户空间缓冲的说法见APUE 5.14:

    One inefficiency inherent in the standard I/O library is the amount of data copying that takes place. When we use the line-at-a-time functions, fgets and fputs, the data is usually copied twice: once between the kernel and the standard I/O buffer (when the corresponding read or writeis issued) and again between the standard I/O buffer and our line buffer.

  • 相关阅读:
    使用cordova开发移动app时用form表单的submit时遇到的问题
    收藏链接
    Hibernate总结
    MyBatis基本应用
    Java中字符串(String)总结
    SpringMVC
    SpringIOC----注解
    栈与堆的区别
    IOS模型
    Java Web容器的启动过程
  • 原文地址:https://www.cnblogs.com/beanmoon/p/2735583.html
Copyright © 2011-2022 走看看