Re: functions order when do memory mapping



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.

--
Måns Rullgård
mru@xxxxxxxxxxxxx
.



Relevant Pages

  • Re: Possible problems with mmap/munmap on FreeBSD ...
    ... >> mmap the region again with a larger size ... >> What I am seeing is that after the munmap the data written to the region ... compares shows expected behavior ...
    (freebsd-hackers)
  • Re: Possible problems with mmap/munmap on FreeBSD ...
    ... >> mmap the tdb file to a region of memory ... >> mmap the region again with a larger size ... >> What I am seeing is that after the munmap the data written to the region ... > for private mappings, but it seems wrong for shared mappings. ...
    (freebsd-hackers)
  • Re: [PATCH 3/5] perf_counter: rework ioctl()s
    ... Paul Mackerras wrote: ... then reopen, and mmap again. ... That is, you don't have to munmap before close, but you do have to do ... both close and munmap to destroy the counter. ...
    (Linux-Kernel)
  • Possible problems with mmap/munmap on FreeBSD ...
    ... I am having some problems with the tdb package on FreeBSD 4.6.2 and 4.10. ... mmap the tdb file to a region of memory ... mmap the region again with a larger size ... What I am seeing is that after the munmap the data written to the region ...
    (freebsd-hackers)
  • Re: Possible problems with mmap/munmap on FreeBSD ...
    ... > mmap the tdb file to a region of memory ... > mmap the region again with a larger size ... > What I am seeing is that after the munmap the data written to the region ... for private mappings, but it seems wrong for shared mappings. ...
    (freebsd-hackers)