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()? 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().
Any comments about how mmap() works will be
appreciated.
Thanks.
Jerry
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/?.refer=text
On 03.30 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()? If this is not
Where did you heard that ?
man mmap(2):
..
MAP_SHARED Share this mapping with all other processes
that map this object. Storing to the region is
equivalent to writing to the file. The file
may not actually be updated until msync(2) or
munmap(2) are called.
..
man msync(2):
..
DESCRIPTION
msync flushes changes made to the in-core copy of a file
that was mapped into memory using mmap(2) back to disk.
Without use of this call there is no guarantee that
changes are written back before munmap(2) is called. To
.
--
J.A. Magallon # Let the source
mailto:[email protected] # be with you, Luke...
Linux werewolf 2.4.2-ac28 #1 SMP Thu Mar 29 16:41:17 CEST 2001 i686
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 <[email protected]> DSA key 0x04880A44
http://home.pages.de/~andreas.bombe/ http://linux1394.sourceforge.net/
> 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).
what about mmap() on non-filesystem files (/dev/mem, /proc/bus/pci...) ?
On Sun, Apr 01, 2001 at 03:28:05PM -0500, Tim Hockin wrote:
> > 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).
>
> what about mmap() on non-filesystem files (/dev/mem, /proc/bus/pci...) ?
They map physically present memory directly and do not have to be
synced, since all writes go directly to their destination (which is of
course not possible with disk files). I'm not that sure if PCI is a bit
special case though, since not all architectures can access it like
memory.
--
Andreas E. Bombe <[email protected]> DSA key 0x04880A44
http://home.pages.de/~andreas.bombe/ http://linux1394.sourceforge.net/