Scatter – gather I/O

To help explain this topic, let's say that we are commissioned with writing data to a file such that three discontiguous data regions A, B, and C are written (filled with As, Bs, and Cs, respectively); the following diagram shows this:

+------+-----------+---------+-----------+------+-----------+|      | ... A ... |         | ... B ... |      | ... C ... |+------+-----------+---------+-----------+------+-----------+|A_HOLE|   A_LEN   | B_HOLE  |   B_LEN   |C_HOLE|  C_LEN    |+------+-----------+---------+-----------+------+-----------+       ^                     ^                  ^       A_START_OFF           B_START_OFF        C_START_OFF
The discontiguous data file

Notice how the files have holes—regions that do not contain any data content; this is possible to achieve with regular files (files that are largely ...

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.