HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
m
mmap(2) mmap(2)
no swap space is initially be reserved for the private mapping. Without this flag, the creation of
a MAP_PRIVATE region reserves swap space equal to the size of the mapping. When a page in
the mapping is first modified (written into), a private page is created and the swap space which
had been reserved is used to hold the private copy of the data in the event of a page-out. An ini-
tial write into a page of a MAP_NORESERVE mapping produces results which depend on the
current availability of system swap space since the swap space reservation occurs at the time of
the first write and only for the affected page. If the swap space reservation can be made for the
page, the write succeeds and is processed as described above; if not, the write fails and a
SIGBUS signal is posted to the writing process for the effective virtual address.
madvise(...,MADV_DONTNEED) on a MAP_NORESERVE object will release swap space
reservations for relevant pages.
If MAP_LOCAL is set in flags:
Memory for this region will be allocated from the current locality domain. This flag overrides the
default allocation policy of first touch. Under a rst touch allocation policy, when memory needs
to be allocated, the locality domain chosen is that of the currently executing process.
The prot argument can be PROT_NONE, or any combination of PROT_READ, PROT_WRITE, and
PROT_EXEC OR’ed together. If
PROT_NONE is not specified, the system may grant other access permis-
sions to the region in addition to those explicitly requested, except that write access will not be granted
unless
PROT_WRITE is specified.
mmap() cannot create a mapped file region unless the file descriptor used to map the file is open for read-
ing. For a mapped file region that is mapped with MAP_SHARED, mmap() grants write access permission
only if the file descriptor is open for writing. If a region was mapped with either
MAP_PRIVATE or
MAP_ANONYMOUS, mmap() grants all requested access permissions.
After the successful completion of
mmap(), fildes can be closed without effect on the mapped region or on
the contents of the mapped file. Each mapped region creates a file reference, similar to an open file
descriptor, that prevents the file data from being deallocated.
Whether modifications made to the file using write() are visible to mapped regions, and whether
modifications to a mapped region are visible with read(), is undefined except for the effect of
msync().
If an enforcement-mode file lock is in effect for any range of a file, a call to
mmap() to map any range of
the file with access rights that would violate the lock fails. The
msem_lock() and msem_unlock()
semaphore interfaces can be used to coordinate shared access to a region created with the MAP_SHARED
flag. The advisory locks of the lockf() or fcntl() interfaces have no effect on memory mapped
access, but they can be used to coordinate shared access to a MAP_SHARED mapped file region.
For a memory mapped file, the st_atime and st_mtime values returned by stat() are updated when a
page in the memory mapped region is read from or written to the file system.
After a call to
fork(), the child process inherits all mapped regions with the same data and the same
sharing and protection attributes as in the parent process. Each mapped file and anonymous memory
region created with mmap() is unmapped upon process exit, and by a successful call to any of the exec
functions.
MAP_NORESERVE attribute is inherited across a fork() call; at the time of the fork(), swap space for
a mapping is reserved in the child only for dirtied private pages that currently exist in the parent;
thereafter the child’s mapping reservation policy is as described above.
A SIGBUS signal is delivered to a process when a write reference to a mapped file region would cause a
file system error condition such as exceeding quota or file system space limits.
A SIGBUS signal is delivered to a process upon a write reference to a region without PROT_WRITE
pro-
tection, or any reference to a region with
PROT_NONE protection.
A call to mmap() with PROT_EXECUTE specified, but without PROT_WRITE specified for a
MAP_SHARED|MAP_FILE mapping is treated by the system as the execution of the underlying file. This
implies that such a call fails if the file is currently open for writing or mapped with
MAP_SHARED|PROT_WRITE options by any process, and that if the call succeeds, the file cannot be
opened for writing or subsequently mapped with MAP_SHARED|PROT_WRITE options as long as such
mappings are present. A files status as an active executable file is determined only at the time of an
exec(), exit(),ormmap() operation. mprotect() operations on a MAP_FILE|MAP_SHARED
mapping have no effect on the underlying file’s status as an active executable file.
HP-UX Release 11i: December 2000 2 Section 2153
___
___