how mmap() works?
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
Quoted 5 lines · 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 needmsync()? 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
.
Signature · 4 lines
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
Quoted 5 lines · Jerry Hong
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 needmsync()?
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.
Quoted 5 lines
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 withoutmsync().
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).
Signature · 2 lines
Andreas E. Bombe <[email protected]> DSA key 0x04880A44 http://home.pages.de/~andreas.bombe/ http://linux1394.sourceforge.net/
Quoted 3 lines
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...) ?
Quoted 5 lines · Tim Hockin
Quoted 3 lines
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.
Signature · 2 lines
Andreas E. Bombe <[email protected]> DSA key 0x04880A44 http://home.pages.de/~andreas.bombe/ http://linux1394.sourceforge.net/