Maps a file or anonymous memory region into the process-address space and attaches the file or memory region to a given resource.
Standard C Library (libc.a)
#include <sys/rset.h>
#include <sys/mman.h>
void * ra_mmap( addr, len, prot, flags, fildes, off, rstype, rsid, policy )
void *addr;
off64_t len;
int prot;
int flags;
int fildes;
off64_t off;
rstype_t rstype;
rsid_t rsid;
unsigned int policy;
void * ra_mmapv( addr, len, prot, flags, fildes, off, rangecnt, rangevec )
void *addr;
off64_t len;
int prot;
int flags;
int fildes;
off64_t off;
int rangecnt;
subrange_t *rangevec;
The ra_mmap subroutine maps the file or memory region, specified by mmap_params, into the process-address space and attaches it to the resource set specified by rstype and rsid. The resource set specified for attachment defines the resource allocation domains (RADs) from which the mapping's memory demands should be fulfilled. If the file or memory region is attached to a resource set specifying multiple RADs, its memory allocation is distributed among these RADs according to policy.
If a file is being mapped, the attachment for the new mapped region is reflected down to the portion of the file it maps and persists after the region is unmapped. The file's attachment persists until the last close of the file.
The ra_mmapv subroutine is similar to the ra_mmap subroutine, and allows multiple subranges of a file or memory region to be attached to different resource sets in a single ra_mmapv call.
The rangecnt argument specifies the number of subranges being mapped. The rangevec argument is a pointer to an array of subrange_t structures describing the attachments to be performed. Each subrange_t structure specifies a portion of the file or memory region and the resource set to which the portion should be attached. If overlapping subranges are specified, ra_mmapv does not fail, but its behavior is undefined.
Child processes inherit all mapped regions and their resource set attachments from the parent process when the fork subroutine is called. The child process also inherits the same sharing and protection attributes for these mapped regions. A successful call to any exec subroutine unmaps all mapped regions created with the ra_mmap subroutine.
Attachments to a given RAD do not attach the process to the processors in that RAD. Attachments are only advisory; memory from a different RAD can be provided if the demand cannot be fulfilled from the RAD specified.
If overlapping subranges are mapped with attachments, the memory placement of the mapped regions is undefined.
The su_rsoffset and su_rslength fields of the subrange_t structures must be set to 0. Otherwise, ra_mmapv fails with EINVAL.
Item | Description |
---|---|
addr | Specifies the starting address of the memory region to be mapped. When the MAP_FIXED flag is specified, this address must be a multiple of the page size returned by the sysconf subroutine using the _SC_PAGE_SIZE value for the Name parameter. A region is never placed at address 0, or at an address where it would overlap an existing region. |
fildes | Specifies the file descriptor of the file-system object or of the shared memory object to be mapped. If the MAP_ANONYMOUS flag is set, the fildes parameter must be -1. After the successful completion of the ra_mmap or ra_mmapv subroutine, the file or the shared memory object specified by the fildes parameter can be closed without affecting the mapped region or the contents of the mapped file. Each mapped region creates a file reference, similar to an open file descriptor, which prevents the file data from being deallocated. |
flags | Specifies attributes of the mapped region. Values
for the flags parameter are constructed
by a bitwise-inclusive ORing of values from the following list of
symbolic names defined in the sys/mman.h file:
|
len | Specifies the length, in bytes, of the memory region to be mapped. The system performs mapping operations over whole pages only. If the len parameter is not a multiple of the page size, the system will include in any mapping operation the address range between the end of the region and the end of the page containing the end of the region. |
off | Specifies the file byte offset at which the mapping starts. This offset must be a multiple of the page size returned by the sysconf subroutine using the _SC_PAGE_SIZE value for the Name parameter. |
Item | Description |
---|---|
policy | Specifies an advisory memory allocation policy
that is to be applied. This parameter must have one of the following
values defined in sys/rset.h:
|
prot | Specifies the access permissions for the mapped
region. The sys/mman.h file defines the
following access options:
Note: The
operating system generates a SIGSEGV signal
if a program attempts an access that exceeds the access permission
given to a memory region. For example, if the PROT_WRITE flag
is not specified and a program attempts a write access, a SIGSEGV signal
results.
If the region is a mapped file that was mapped with
the MAP_SHARED flag, the ra_mmap or ra_mmapv subroutine
grants read or execute access permission only if the file descriptor
used to map the file was opened for reading. It grants write access
permission only if the file descriptor was opened for writing. If
the region is a mapped file that was mapped with the MAP_PRIVATE flag,
the ra_mmap or ra_mmapv subroutine
grants read, write, or execute access permission only if the file
descriptor used to map the file was opened for reading. If the region
is an anonymous memory region, the ra_mmap or ra_mmapv subroutine
grants all requested access permissions. |
rangecnt | Specifies the number of subrange_t structures pointed to by rangevec. |
rangevec | Specifies a pointer to an array of subrange_t structures describing the desired subrange attachments. |
rsid | Identifies the resource to be attached to the
file or memory region. All attachments are advisory. If memory cannot
be allocated from the RADs identified by the resource, memory is allocated
from any RAD in the system.
|
rstype | Specifies the type of resource the file or memory
region is to be attached to. This parameter must have one of the following
values:
|
Upon successful completion, an address to the mapped file or memory region is returned. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.
Item | Description |
---|---|
EACCES | The file referred to by the fildes parameter is not open for read access, or the file is not open for write access and the PROT_WRITE flag was specified for a MAP_SHARED mapping operation. Or, the file to be mapped has enforced locking enabled and the file is currently locked. |
EAGAIN | The fildes parameter refers to a device that has already been mapped. |
EBADF | The fildes parameter is not a valid file descriptor, or the MAP_ANONYMOUS flag was set and the fildes parameter is not -1. |
EFBIG | The mapping requested extends beyond the maximum file size associated with fildes. |
EINVAL | The flags or prot parameter is invalid, or the addr parameter or off parameter is not a multiple of the page size returned by the sysconf subroutine using the _SC_PAGE_SIZE value for the Name parameter. |
EINVAL | The application has requested SPEC1170 compliant behavior and the value of flags is invalid (neither MAP_PRIVATE nor MAP_SHARED is set). |
EINVAL | The subrange_t structure specifies an invalid range. |
EINVAL | The su_rsoffset and su_rslength fields of a subrange_t do not have a value of 0. |
EINVAL | The resource type is invalid (is not of type R_RSET). |
EINVAL | The application has requested SPEC1170 compliant behavior and the value of flags is invalid (neither MAP_PRIVATE nor MAP_SHARED is set). |
EMFILE | The application has requested SPEC1170 compliant behavior and the number of mapped regions would exceed an implementation-dependent limit (per process or per system). |
ENODEV | The fildes parameter refers to an object that cannot be mapped, such as a terminal. |
ENODEV | An invalid rsid SRADID is specified. |
ENOMEM | There is not enough address space to map len bytes, or the application has not requested Single UNIX Specification, Version 2 compliant behavior and the MAP_FIXED flag was set and part of the address-space range (addr, addr+len) is already allocated. |
ENOSYS | The ra_mmap subroutine is not supported on the system. |
ENOSYS | The file specified is of a type that does not support physical attachments. |
ENOTSUP | An attempt to map a memory region with an SRADID attachment is made and ENHANCED_AFFINITY is disabled. |
ENOTSUP | An attempt to map a file with an SRADID attachment was made. |
ENXIO | The addresses specified by the range (off, off+len) are invalid for the fildes parameter. |
EOVERFLOW | The mapping requested extends beyond the offset maximum for the file description associated with fildes. |
EPERM | The calling process does not have the necessary attachment privileges. |