A quick summation of a few additional points to wrap up the memory mapping discussion follows:
- The fourth parameter to mmap(2), flags, can take on several other (quite interesting) values; we refer the reader to the man page on mmap(2) to browse through them: http://man7.org/linux/man-pages/man2/mmap.2.html.
- Directly analogous to how we can give hints or advice to the kernel regarding kernel page cache pages with the posix_fadvise(2) API, you can provide similar hints or advice to the kernel regarding memory usage patterns for a given memory range (start address, length provided) via the posix_madvise(3) library API. The advice values include being able to say that we expect random access to data (thereby ...