Brief introduction:
Memory-mapped files are somewhat similar to virtual memory, where a memory-mapped file preserves an area of an address space and submits the physical memory to this zone, except that the physical memory of the memory-file mapping comes from a file that already exists on disk, not the system's page file. And before you can manipulate the file, you must first map the file as if you were loading the entire file from disk into memory. As you can see, using a memory-mapped file to process files stored on disk eliminates the need to perform I/O operations on files (virtual memory needs to be added from disk to physical memory), which means that files are no longer requested and allocated for caching when they are processed . All file caching operations are managed directly by the system, and the memory-mapped file can play a significant role in processing large data volumes by canceling the steps such as loading the file data into memory, data from memory to file writeback, and freeing memory blocks . In addition, the actual project in the system often need to share data between multiple processes, if the amount of data is small, the processing method is flexible, if the shared data capacity is huge, then need to use the memory map file. In fact, a memory-mapped file is the most efficient way to resolve data sharing across multiple processes on-premises.
On the internet to find some code, their own processing after the Linux compiled through, you can run to achieve the corresponding functions.
Transferred from: http://blog.csdn.net/yasaken/article/details/7229076
Introduction to the usage of memory-mapped files under Linux (RPM)