You could mmap large area where the size is the sum of the sizes of all the files using MAP_PRIVATE | MAP_ANON MAP_PRIVATE | MAP_ANON and MAP_PRIVATE | MAP_ANON protection, which would prevent the OS from unnecessarily performing a memory card.
This will reserve, but not freeze, the memory.
You can then open file filename1 in [baseAddr, size1) and open filename2 in [baseAddr + size1, baseAddr + size1 + size2) , etc.
I believe the flags for this are MAP_FIXED | MAP_PRIVATE MAP_FIXED | MAP_PRIVATE .
source share