Fast Scatter-Gather I/O
Some applications may need to read or write data to multiple buffers, which are separated in memory. Although this can be done easily enough with multiple calls to read and write, it is inefficient because there is overhead associated with each kernel call.
Instead, many platforms provide special high-speed primitives to perform these scatter-gather operations in a single kernel call. The GNU C library will provide an emulation on any system that lacks these primitives, so they are not a portability threat. They are defined in sys/uio.h.
These functions are controlled with arrays of iovec structures, which describe the location and size of each buffer.
The
iovecstructure describes a buffer. It contains two fields:
void *iov_base- Contains the address of a buffer.
size_t iov_len- Contains the length of the buffer.
The
readvfunction reads data from filedes and scatters it into the buffers described in vector, which is taken to be count structures long. As each buffer is filled, data is sent to the next.Note that
readvis not guaranteed to fill all the buffers. It may stop at any point, for the same reasonsreadwould.The return value is a count of bytes (not buffers) read, 0 indicating end-of-file, or -1 indicating an error. The possible errors are the same as in
read.
The
writevfunction gathers data from the buffers described in vector, which is taken to be count structures long, and writes them tofiledes. As each buffer is written, it moves on to the next.Like
readv,writevmay stop midstream under the same conditionswritewould.The return value is a count of bytes written, or -1 indicating an error. The possible errors are the same as in
write.
Note that if the buffers are small (under about 1kB), high-level streams may be easier to use than these functions. However, readv and writev are more efficient when the individual buffers themselves (as opposed to the total output), are large. In that case, a high-level stream would not be able to cache the data effectively.
阅读(692) | 评论(0) | 转发(0) |
-->
Fast Scatter-Gather I/O的更多相关文章
- JAVA NIO Scatter/Gather(矢量IO)
矢量IO=Scatter/Gather: 在多个缓冲区上实现一个简单的IO操作.减少或避免了缓冲区拷贝和系统调用(IO) write:Gather 数据从几个缓冲区顺序抽取并沿着通道发送,就好 ...
- 转:Java NIO系列教程(四) Scatter/Gather
Java NIO开始支持scatter/gather,scatter/gather用于描述从Channel(译者注:Channel在中文经常翻译为通道)中读取或者写入到Channel的操作.分散(sc ...
- java的nio之:java的nio系列教程之Scatter/Gather
一:Java NIO的scatter/gather应用概念 ===>Java NIO开始支持scatter/gather,scatter/gather用于描述从Channel(译者注:Chann ...
- Java基础知识强化之IO流笔记75:NIO之 Scatter / Gather
1. Java NIO开始支持scatter/gather,scatter/gather用于描述从Channel(译者注:Channel在中文经常翻译为通道)中读取或者写入到Channel的操作. 分 ...
- Java NIO Scatter / Gather
原文链接:http://tutorials.jenkov.com/java-nio/scatter-gather.html Java NIO发布时内置了对scatter / gather的支持.sca ...
- Java NIO中的通道Channel(二)分散/聚集 Scatter/Gather
什么是Scatter/Gather scatter/gather指的在多个缓冲区上实现一个简单的I/O操作,比如从通道中读取数据到多个缓冲区,或从多个缓冲区中写入数据到通道: scatter(分散): ...
- NIO相关概念之Scatter / Gather
Scatter /Gather 是java NIO中用来对channel的读取或者写入操作的特殊的形式的描述 Scatter(发散) 是指在读操作的时候,从chanel读取到的数据,写入到多个buff ...
- Java NIO系列教程(四) Scatter/Gather
Java NIO开始支持scatter/gather,scatter/gather用于描述从Channel(译者注:Channel在中文经常翻译为通道)中读取或者写入到Channel的操作.分散(sc ...
- NIO学习笔记六:channel 之前数据传输及scatter/gather
在Java NIO中,如果两个通道中有一个是FileChannel,那你可以直接将数据从一个channel传输到另外一个channel. FileChannel的transferFrom()方法可以将 ...
- 【Java NIO的深入研究6】JAVA NIO之Scatter/Gather
Java NIO开始支持scatter/gather,scatter/gather用于描述从Channel(译者注:Channel在中文经常翻译为通道)中读取或者写入到Channel的操作. 分散(s ...
随机推荐
- 我的 Linux 配置
系统版本 Ubuntu 18.04 一名老年弱智 OI 选手的 Linux 配置 文本编辑器: Sublime Text 中文补丁,关闭自动补全,自动联想,括号匹配,字号 15 编译器: g++ (然 ...
- HDU - 5412 CRB and Queries (整体二分)
题目链接 动态区间第k小,但是这道题的话用主席树+树状数组套线段树的空间复杂度是O(nlog2n)会爆掉. 另一种替代的方法是用树状数组套平衡树,空间复杂度降到了O(nlogn),但我感觉平衡树是个挺 ...
- ProjectEuler654
我,ycl:BM是什么早就忘了! 毕老爷:那你们可以做一做这道题练练BM板子啊. 传送门 //Achen #include<bits/stdc++.h> #define For(i,a,b ...
- Directx 9 VS2015环境搭建
安装好Directx9 sdk和vs2015后 打开vs,新建项目 --> c++项目 -->win32控制台应用程序-->空项目 创建项目后,右键项目属性, 包含目录 D:\Pr ...
- ubuntu tftp server config
1.安装tftp-server sudo apt-get install tftpd-hpa sudo apt-get install tftp-hpa(如果不需要客户端可以不安装) tftp-hpa ...
- nginx之 [error] 6702#0:XXX is forbidden (13: Permission denied)
问题描述: 配置完 nginx 两个虚拟机后,客户端能够访问原始的server ,新增加的 server 虚拟机 不能够访问,报错如下页面 解决过程: 1. 查看报错日志[root@mysql03 n ...
- 【转载,实测好用】gitlab结合sourcetree使用
转载 的出处http://blog.csdn.net/u012764358/article/details/62886427 Gitlab和Sourcetree结合使用实现代码管理 这是本人第一次发表 ...
- hl7消息中和时间有关的字段的格式
hl7消息中有许多segment(段)包含时间类型的Field.常用的MSH, EVN, PID中的时间字段及其格式为: 1. MSH-7, Date/time Of Message为yyyyMMdd ...
- setcookie函数的注意事项
函数说明 bool setcookie ( string $name [, string $value = "" [, int $expire = 0 [, string $pat ...
- HTTP-Runoob:HTTP状态码
ylbtech-HTTP-Runoob:HTTP状态码 1.返回顶部 1. HTTP状态码 当浏览者访问一个网页时,浏览者的浏览器会向网页所在服务器发出请求.当浏览器接收并显示网页前,此网页所在的服务 ...