Welcome! Log In Create A New Profile

Why mmap write back deferred?

Posted by Yong 
Why mmap write back deferred?
September 24, 2008 09:23AM
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
Re: Why mmap write back deferred?
September 24, 2008 09:26AM
Forgot to indicate the parameters when we call mmap(). It's operating in the MAP_SHARED mode with PROT_READ|PROT_WRITE permission.
Thanks again for your time. Have a nice day.

Regards,
Yong
Re: Why mmap write back deferred?
November 23, 2009 12:11PM
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
Author:

Your Email:


Subject:


Message: