I am using mmap() to map device file "mtdblock0" into virtual address space of one process1. Some data whose value changes continuously for some time are stored in memory mapped region as well. I want to prevent these data changes to be flushed from memory mapped region to the device file for some time until the calculations are over(so that process2 which is mapping to the same file does not see these changes). Note: The same device file is mapped by another process also to read the data.
Assuming that mmap() syncing works for the device files in the same way as for regular files, I tried setting "dirty_writeback_centisecs" to 0 to disable the kernel threads that perform the flushing. Then I'm setting "dirty_writeback_centisecs" to default value after some time to again enable the flushing. This is working partially. But the data is still getting flushed to the device file occassionally even when "dirty_writeback_centisecs" is 0. Please help me to know why this is not working.
Does the mmap() syncing works for the device files in the same way as for regular files?
Are the same set of threads that are responsible for flushing the page cache are also responsible for flushing the memory mapped region to the underlying file?
Files mapped using mmap() are directly mapped from the disk to the virtual address space of process. They don't use intermediate page cache. So any flushing done through msync() happens directly between memory map and disk. Is my understanding right?
If this method is not possible, are there any other ways of achieving this?(I have tried mysnc() with INVALIDATE and it does not work)