I have a producer process, that writes to a mmap’d file and a consumer process that reads from it. This is on Linux.
If the producer makes a change to the mmap and its not instantly flushed, when the consumer access it what happens? Will it get the old version from the disk, or is it clever enough to get the unflushed page?
From the
mmap()manual page:Bottom line: changes will be immediately visible to other processes if you specify so when calling
mmap(). According to the documentation you have to use eitherMAP_SHAREDorMAP_PRIVATE, which controls the behaviour with regard to other processes mapping the same file area.