HP-UX Reference (11i v2 07/12) - 2 System Calls (vol 5)

m
mmap(2) mmap(2)
MAP_GLOBAL Allocate physical memory from the global quadrant / octant.
MAP_IO Create a virtual mapping for a physical I/O address range.
MAP_MEM_INTERLEAVED
Physical memory will be interleaved.
MAP_MEM_LOCAL Allocate physical memory from the current locality domain.
MAP_MEM_FIRST_TOUCH
Allocate physical memory from the locality domain of the first processor
to touch each address.
The
MAP_PRIVATE and MAP_SHARED flags control the visibility of write references to the memory
region. Exactly one of these flags must be specified. A
MAP_IO mapping can not be mapped private and
must use the
MAP_SHARED flag. The mapping type is retained across a
fork().
If
MAP_SHARED is set in flags, write references to the memory region by the calling process may change
the file and are visible in all
MAP_SHARED mappings of the same portion of the file by any process of the
same executable type. That is, an application compiled as a 32-bit process will be able to share the same
mappings with other 32-bit processes, and an application compiled as a 64-bit process will be able to share
the same mappings with other 64-bit processes.
If a 64-bit and a 32-bit application want to share the same mapping, both
MAP_ADDR32 and
MAP_SHARED must be set in ags by the 64-bit application. The 32-bit application does not need to set
MAP_ADDR32 in flags. When MAP_SHARED is set in flags, write references to the memory region by the
calling process may change the file. Changes are visible in all 32-bit processes which specify MAP_SHARED
and by all 64-bit processes which specify both MAP_SHARED and MAP_ADDR32 for the same portion of the
file. Mappings created using the MAP_IO flag do not currently support usage of the MAP_ADDR32
flag.
Programs running on PA-RISC platforms may still share between 64-bit and 32-bit processes by mapping to
the 32-bit processes first. Programs running on Itanium-based platforms will share the mapped range of
I/O address space, but the virtual address range given to a 32-bit process will differ from that assigned to a
64-bit process.
On Itanium-based platforms, 64-bit MPAS (Mostly Private Address Space) and MGAS (Mostly Global
Address Space) processes can share between themselves without incurring the cost of aliasing by specifying
the
MAP_GLOBAL flag without specifying the MAP_ADDR32 flag. Such mappings are not accessible by
32-bit processes. See the Adaptive Address Space Whitepaper for details.
If MAP_PRIVATE is set in flags, write references to the memory region by the calling process do not
change the file and are not visible to any process in other mappings of the same portion of the file.
It is unspecified whether write references by processes that have mapped the memory region using
MAP_SHARED are visible to processes that have mapped the same portion of the file using
MAP_PRIVATE .
It is also unspecified whether write references to a memory region mapped with MAP_SHARED are visible
to processes reading the file and whether writes to a file are visible to processes that have mapped the
modified portion of that file, except for the effect of
msync()
.
The
MAP_VARIABLE and MAP_FIXED flags control the placement of the region as described below.
Exactly one of these flags must be selected, with the exception of MAP_IO mappings. MAP_IO regions
must be placed by the system and do not support
MAP_FIXED requests.
Usage of MAP_VARIABLE with MAP_IO is recommended, but not required since MAP_IO implicitly
includes this attribute in the request.
If MAP_VARIABLE is set in flags, and the requested address addr is NULL, or if it is not possible for the
system to place the region at the requested address, the region is placed at an address selected by the sys-
tem. If the requested address is not a multiple of the page size returned by
sysconf(_SC_PAGE_SIZE), the system treats the address as if it were rounded up to the next larger
page size multiple.
When MAP_FIXED is set in the flags argument, the implementation is informed that the value of pa must
be addr, exactly. If
MAP_FIXED is set, mmap() may return MAP_FAILED and set errno to [EINVAL].
If a MAP_FIXED request is successful, the mapping established by mmap() replaces any previous map-
pings for the process pages in the range [pa, pa+len].
When MAP_FIXED is not set, the implementation uses addr in an unspecified manner to arrive at pa. The
pa so chosen will be an area of the address space which the implementation deems suitable for a mapping
of len bytes to the file. All implementations interpret an addr value of 0 as granting the implementation
complete freedom in selecting pa, subject to constraints described below. A non-zero value of addr is taken
to be a suggestion of a process address near which the mapping should be placed. When the
HP-UX 11i Version 2: December 2007 Update 2 Hewlett-Packard Company 185