public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* how mmap() works?
@ 2001-03-29 22:14 Jerry Hong
  2001-03-29 22:38 ` J . A . Magallon
  2001-04-01 16:41 ` Andreas Bombe
  0 siblings, 2 replies; 5+ messages in thread
From: Jerry Hong @ 2001-03-29 22:14 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how mmap() works?
  2001-03-29 22:14 how mmap() works? Jerry Hong
@ 2001-03-29 22:38 ` J . A . Magallon
  2001-04-01 16:41 ` Andreas Bombe
  1 sibling, 0 replies; 5+ messages in thread
From: J . A . Magallon @ 2001-03-29 22:38 UTC (permalink / raw)
  To: Jerry Hong; +Cc: linux-kernel


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:jamagallon@able.es                              #  be with you, Luke... 

Linux werewolf 2.4.2-ac28 #1 SMP Thu Mar 29 16:41:17 CEST 2001 i686


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how mmap() works?
  2001-03-29 22:14 how mmap() works? Jerry Hong
  2001-03-29 22:38 ` J . A . Magallon
@ 2001-04-01 16:41 ` Andreas Bombe
  2001-04-01 20:28   ` Tim Hockin
  1 sibling, 1 reply; 5+ messages in thread
From: Andreas Bombe @ 2001-04-01 16:41 UTC (permalink / raw)
  To: Jerry Hong; +Cc: linux-kernel

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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how mmap() works?
  2001-04-01 16:41 ` Andreas Bombe
@ 2001-04-01 20:28   ` Tim Hockin
  2001-04-02  0:42     ` Andreas Bombe
  0 siblings, 1 reply; 5+ messages in thread
From: Tim Hockin @ 2001-04-01 20:28 UTC (permalink / raw)
  To: Andreas Bombe; +Cc: Jerry Hong, linux-kernel

> 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...) ?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how mmap() works?
  2001-04-01 20:28   ` Tim Hockin
@ 2001-04-02  0:42     ` Andreas Bombe
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Bombe @ 2001-04-02  0:42 UTC (permalink / raw)
  To: Tim Hockin; +Cc: linux-kernel

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 <andreas.bombe@munich.netsurf.de>    DSA key 0x04880A44
http://home.pages.de/~andreas.bombe/    http://linux1394.sourceforge.net/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-04-02  0:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-03-29 22:14 how mmap() works? Jerry Hong
2001-03-29 22:38 ` J . A . Magallon
2001-04-01 16:41 ` Andreas Bombe
2001-04-01 20:28   ` Tim Hockin
2001-04-02  0:42     ` Andreas Bombe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox