If it's MAP_SHARED, you can look at msync() to flush the memory immediately.
Anonymous User Wrote:
-------------------------------------------------------
> In one project, I am suprising to see the content
> in the memory cannot be flushed onto the disk file
> on time,
> instead it may experience some delay, 1-2 minutes
> at most. Although the case is rare, it is not
> acceptable
> for my application. So, could anyone help to look
> into this issue and tell me the potential reason?
> Thanks
> in advance.
>
> In this project, I mapped one file on disk into
> memory via mmap(), then I copy the memory into
> another buffer.
> After I did some operations on the buffer, just
> copy the buffer into the memory we mapped via
> mmap(). To
> ensure the change flushed back onto the file, call
> the msync() then do the munmap(). That's my
> operation,
> very straight forward, :-). But sometimes, I found
> the timestamp of the file (via ls -l filename) was
> updated after
> 1-2 minutes.
>
> Could you please take a look at the issue above?
> Thanks so much.
>
> Regards,
> Yong