你是不是说gcc的read/write?
搞不懂你的意思
man 2 write
ssize_t write(int fd, const void *buf, size_t count);
说write 从buf所指的缓存中读取count个字节数据写入fd所对应的文件描述符(socket等)中去,返回实际写入数据字节数 -1为没有写入,出错则错误代码保留在errno变量中
是系统调用,就是直接内核的调用了
用户缓存就是 buf(当然你先要malloc申请)
内核缓存??不知道
对于mmap
quote:
”对mmap()的描述是:
内核直接对映射存储缓存作I/O操作。
mmap是我心中默认的方式。“
搞不懂
man 2 mmap
void * mmap(void *start, size_t length, int prot , int flags, int fd,off_t offset);
DESCRIPTION
The mmap function asks to map length bytes starting at offset offset from the file (or other object) specified by the file descriptor fd into memory,preferably at address start. This latter address is a hint only, and is usually specified as 0. The actual place where the object is mapped is returned by mmap, and is never 0.
大概就是mmap这个函数从fd文件描述府中start指向的地址开始偏移offset字节找length长的数据,(start一般设为0);并把这些数据复制,最后mmap返回这些数据的地址。
port参数是描述内存保护模式的设置(一定要不能对文件的open mode模式有冲突),可以用PORT_NONE或者用OR(就是或操作)方式采用一中或几种PROT_* flags。
不知翻译的对不对? |