The ministry of strange syscalls
My favorite syscall today:
$ man 2 readahead
"readahead() populates the page cache with data from a file so that subsequent reads from that file will not block on disk I/O."
I don't really know when should I use that, but it sounds cool. Just an implementation of prefetching on yet another layer. Wait a moment...
"readahead() blocks until the specified data has been read. "
I'm lost. If it blocks, why not to just use read(2)?
Second syscall:
$ man 2 madvise
"The madvise() system call advises the kernel about how to handle paging input/output in the address range beginning at address start and with size length bytes"
"The kernel is free to ignore the advice."
I don't get when I should use it.
And the last one:
$ man 2 mincore
"mincore() returns a vector that indicates whether pages of the calling process’s virtual memory are resident in core (RAM), and so will not cause a disk access (page fault) if referenced."
Cool, I can check if my memory page is in swap. I doubt it can help me in anything. If I don't want my pages to be in swap I'll just use mlock(2)...
Probably there are dozens of strange syscalls out there!