14 高级IO非阻塞IO:这里我要抽时间看看AIO的使用。记录锁:运行一个进程修改一个文件的一部分的时候,禁止其进程修改统一区域。流在用户经常和设备驱动程序间提供了一个全双工通道。readv和writev:散布读和聚集写。散布读:将文件中的数据一次读到多个缓冲区中;聚集写:将多个缓冲区的数据一次写到文件中。好处是完成统一的操作,可以使用更少的系统调用。readn和writen向管道,fifo,终端,网络等读或者写直到操作n个字节。mmap:这个函数还是非常有用的:void *mmap(void *addr, size_t len, int prot, int flag, int fileds, off_t off)addr一般设置为0.有更好的移植性。off和addr通常是虚存页长整数倍。映射区部分在栈与堆之间。fork后,子进程继承映射区。执行exec后不继承映射区。msync可以将映射区中的更改同步到文件中。munmap解除映射。但不会使映射区的内容写到文件中。通过映射写入文件中时,需要设置(lseek,然后write一个字节)文件的长度,保证它足够大。否则会引起总线错误。存储区映射可以用来提高IO速度:比如文件复制,可以减少内核缓冲区到应用程序缓冲区的复制。也可以用作进程间通信:共享存储区。映射后,修改文件不会同步到内存中。15 进程间通信管道:最古老的IPC。半双工。类似于
...
继续阅读
(21)