且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

[深入理解文件系统之一] IO系统调用

更新时间:2022-09-03 22:16:44


1. IO system call


six basic operation:


open

create

close

write

read

lseek


ioctl

unlink



更高级的IO system call:


pread

pwrite


readv

writev


preadv (calls combine the effects of lseek() and read() (or write()) into a single system call.)

pwritev


aio_read

aio_write

lio_listio



unlink

flush

dup2


2.  文件中datameta-datacache属性:


O_SYNC: write operation returns only when both data and meta data stored on physical disk


O_DSYNC: write operation   returns only when data  stored on physical disk


O_RSYNC: read operation returns before time-stamp updated


O_DIRECT: return only when data submitted to disk driver's IO queue (?)



3. memory mapped files

根本功能是:把一个文件映射到当前进程的用户空间


4. stdio file operation

重点是理解下面的数据结构,他说unistd.h file IO stdlib.hfile io的接口:

struct _IO_FILE {

char *_IO_read_ptr;

/*

Current read pointer */

char *_IO_read_end;

/*

End of get area. */

char *_IO_read_base;

/*

Start of putback and get area. */

char *_IO_write_base;

/*

Start of put area. */

char *_IO_write_ptr;

/*

Current put pointer. */

char *_IO_write_end;

/*

End of put area. */

char *_IO_buf_base;

/*

Start of reserve area. */

char *_IO_buf_end;

/*

End of reserve area. */

int

int

_blksize;

_fileno;


};


typedef struct _IO_FILE FILE;


学习并了解到的新的函数:

setbuf();

setvbuf()

setbuffer();

setvbuf()


文中还提供了经典的例子,来对比和分析NON buffer/Line buffer/File buffer对性能的不同影响。 还有一个重要的思想就是:如果对性能要求很高,需要尽可能地bypass std io library


















本文转自存储之厨51CTO博客,原文链接:http://blog.51cto.com/xiamachao/1891178 ,如需转载请自行联系原作者