Fast resize of a mmap file
I need a copy-free re-size of a very large mmap file while still allowing concurrent access to reader threads. The simple way is to use two MAP_SHARED mappings (grow the file, then create a second mapping that includes the grown region) in the same process over the same file and then unmap the old mapping once all readers that could access it are finished. However, I am curious if the scheme below could work, and if so, is there any advantage to it. mmap a file with MAP_PRIVATE do read-only access to this memory in multiple threads either acquire a mutex for the file, write to the memory