Re: functions order when do memory mapping




"Måns Rullgård" <mru@xxxxxxxxxxxxx>
??????:yw1xzm9dl1du.fsf@xxxxxxxxxxxxxxxxxxxxxxxx
Ronald <followait@xxxxxxx> writes:

A:
open
mmap
....
munmap
close

or

B:
open
mmap
close
....
munmap

Both works well, I wonder which is better?

It doesn't matter in general. The only time it could possibly matter
is if the file is deleted while open and/or mapped. In both cases,
the OS keeps reference counts on the inode so everything works.

If so, I think the 2nd is better.


.



Relevant Pages

  • Re: sharing memory map between processes (same parent)
    ... reference in terms of an open descriptor because the descriptor can be ... closed after mmap(), and the file is still mapped. ... Once you've called mmap for a given file descriptor, the incore inode ... will get an additional reference from the mapping. ...
    (comp.unix.programmer)
  • Re: sharing memory map between processes (same parent)
    ... | will get an additional reference from the mapping. ... | which follows the mmap, simply releases the file descriptor, but because ... | inode remains in memory until unmap or exit. ...
    (comp.unix.programmer)
  • Re: functions order when do memory mapping
    ... Ronald writes: ... It doesn't matter in general. ...
    (comp.os.linux.development.system)
  • Re: mmap
    ... it doesn't matter if you use openor ... "offset" argument with mmap(). ... Greg is quite right: do not use PHYSBASE ...
    (comp.os.lynx)
  • Re: mmap
    ... it doesn't matter if you use openor ... you could pass to mmap(). ... I think Greg actually wrote that code for a ... >addressing. ...
    (comp.os.lynx)