I have a large file that needs to be accessed (read-only) by several processes. I would like to load the file content into volatile memory at boot and then have the processes access it without communicating with each other.
I was thinking of setting aside physical memory for this purpose, and then hardcode the same physical address in each process. I would let each process make its own mapping to virtual memory, and have one of them write load the file content at boot. Is this possible on Linux (Android)? Is there a better way?
Some more perspective. The file is ~0.5 GB and it's important that read is as fast as possible. Yet the memory is restricted (embedded) so I don't want to have multiple copies of the same file in physical memory. Ideally, I would set aside a contiguous portion of physical memory.
From what I know about mmap, it doesn't load the file directly into memory, instead, it does so in a lazy manner, neither does it allow one to specify which physical memory to allocate to?
I'm thinking about using ION since I am on Android, but it seems to require IPC for sharing a memory handle.
question from:
https://stackoverflow.com/questions/65935719/share-a-file-in-volatile-memory-between-processes-without-ipc 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…