Here is a solution to these issues: memory mapping via the mmap(2) system call. Linux provides the very powerful mmap(2) system call; it enables the developer to map any content directly into the process virtual address space (VAS). This content includes file data, hardware device (adapter) memory regions, or just generic memory regions. In this chapter, we shall only focus on using mmap(2) to map in a regular file's content into the process VAS. Before getting into how the mmap(2) becomes a solution to the memory wastage issue we just discussed, we first need to understand more about using the mmap(2) system call itself.
The signature of the mmap(2) system call is shown here:
#include <sys/mman.h>void *mmap(void ...