Saturday, November 22, 2014

Scatter/Gather IO

One single system call to read or write data into a string of non-contiguous buffers.  Its advantage is performance due to reduction of overhead comparing to a serial of individual read or write system calls.  In addition, the call is atomic and it will not interleave with calls from other threads.

readv() and writev() accept 3 parameters - a fd, an array of iovec structure and a count of the number of buffers.

struct iovec {
    void *iov_base  /* ptr to the start of buffer */
    size_t iov_len
}

The buffers are processed sequentially.

No comments: