Re: how mmap() works?

Andreas Bombe (andreas.bombe@munich.netsurf.de)
Sun, 1 Apr 2001 18:41:31 +0200


On Thu, Mar 29, 2001 at 02:14:51PM -0800, Jerry Hong wrote:
> Hi,
> mmap() creates a mmaped memory associated with a
> physical file. If a process updates the mmaped memory,
> Linux will updates the file "automatically". If this
> is the case, why do we need msync()?

For the same reason you might need fsync() or fdatasync(). To force
changes to be written now, without having to munmap() the area, so that
you have a gurantee that current data is on disk and will not be lost.

> If this is not
> the case, what is the interval between 2 "WRITE" (IO
> request operation) request to the physical file
> because it really updates the physical file somehow
> even without msync().

Without syncing, Linux writes whenever it thinks it's appropriate, e.g.
when pages have to be freed (I think also when the bdflush writes back
data, i.e. every 30 seconds by default).

-- 
 Andreas E. Bombe <andreas.bombe@munich.netsurf.de>    DSA key 0x04880A44
http://home.pages.de/~andreas.bombe/    http://linux1394.sourceforge.net/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/