Via the readahead(2) API

The Linux (GNU)-specific readahead(2) system call achieves a similar result as the posix_fadvise(2) we just saw in terms of performing aggressive file read-ahead. Its signature is as follows:

include <fcntl.h>ssize_t readahead(int fd, off64_t offset, size_t count);

The read-aheads are performed on the target file specified by fd, starting from the file offset and for a maximum of count bytes (rounded up to page granularity).

Though not normally required, what if you want to explicitly empty (clean) the contents of the Linux kernel's page cache? If required, do this as the root user: # sync && echo 1 > /proc/sys/vm/drop_caches Don't miss the sync(1) first, or you risk losing data. Again, we stress that flushing ...

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.