SG – I/O variations

Recall from the MT app file I/O with the pread, pwrite APIs section, we could use the pread(2) and pwrite(2) system calls to effectively perform file I/O in parallel via multiple threads (in a multithreaded app). Similarly, Linux provides the preadv(2) and the pwritev(2) system calls; as you can guess, they provide the functionality of the readv(2) and writev(2) with the addition of a fourth parameter offset; just as with the readv(2) and writev(2), the file offset at which SG-IO is to be performed can be specified and it will not be changed (again, perhaps useful for an MT application). The signature of the preadv(2) and pwritev(2) is shown here:

#include <sys/uio.h>ssize_t preadv(int fd, const struct iovec *iov, int ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.