NAME | SYNOPSIS | FEATURES | DESCRIPTION | RESTRICTION | RETURN VALUE | ERRORS | ATTRIBUTES | SEE ALSO
#include <sys/mman.h>void *mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off);
POSIX_SHM
The mmap system call establishes a mapping between the c_actor's address space and a shared memory object. The format of the call is as follows:
pa = mmap(addr, len, prot, flags, fildes, off); |
It establishes a mapping between the c_actors's address space at an address pa for len bytes and the memory object represented by the file descriptor fildes at offset off for len bytes. The fildes parameter must have been obtained by a successful call to shm_open. The value of pa is a function of the parameter addr and the values of flags, described below. The off value must be a multiple of the page size (as returned by vmPageSize(2K)). A successful mmap call returns pa as its result. The address range starting at pa and continuing for len is legitimate for the current address space of the c_actor; this memory is locked. The range of bytes starting at off and continuing for len bytes is legitimate for the current offsets in the shared memory object represented by fildes.
The mapping established by mmap uses a free address range for those whole pages containing any part of the c_actor's address space starting at pa and continuing for len bytes.
The parameter prot determines the access permissions to the data being mapped. The prot parameter should be the bitwise inclusive OR of one or more of the other flags listed below and defined in the header <sys/mman.h>.
Data can be read.
Data can be written.
Data can be executed.
The behavior of PROT_WRITE is influenced by setting MAP_PRIVATE in the flags parameter as described below.
The flags parameter provides other information about the handling of the mapped data. The value of flags is the bitwise inclusive OR of these options as defined in the header <sys/mman.h>.
Changes are shared.
Changes are private.
Interpret addr exactly.
The MAP_SHARED and MAP_PRIVATE flags describe the disposition of write references to the memory object. If MAP_SHARED is specified, write references change the underlying object. If MAP_PRIVATE is specified, modifications to the mapped data by the calling c_actor are visible only to the calling c_actor and will not change the underlying object. Either MAP_SHARED or MAP_PRIVATE may be specified, but not both.
The MAP_FIXED flag tells the system that the value of pa is addr exactly.
When MAP_FIXED is not set, the addr parameter is ignored. The pa will be placed in an area of address space defined by the system for mapping of len bytes to the specified object.
If MAP_FIXED is set, the implementation requires that addr is a multiple of the page size (as returned by vmPageSize(2K)). The system performs mapping operations over whole pages. Thus, while the parameter len need not meet a size or alignment constraint, the system will include, in any mapping operation, any partial page specified by the address range starting at pa and continuing for len bytes.
The system always zero-fills any partial page at the end of an object.
If the size of the object is zero, mmap fails and returns the [EAGAIN] error code .
The PROT_NONE option is not supported.
Upon successful completion, mmap returns the address at which the mapping was placed (pa); otherwise, it returns a value of MAP_FAILED and sets errno to indicate the error condition. The symbol MAP_FAILED is defined in the header <mman.h>.
The mmap function is not supported.
The POSIX_SHM feature is not configured.
The value in flags is invalid, neither MAP_PRIVATE nor MAP_SHARED is defined.
fildes is not a valid open file descriptor.
The fildes argument refers to an object for which mmap is not supported, such as a file.
off is not a multiple of page size. Or MAP_FIXED was specified and addr is not a multiple of page size.
The file descriptor fildes is not open for read access, regardless of the protection specified.
The file descriptor fildes is not open for write access and PROT_WRITE was specified for MAP_SHARED type mapping.
The addresses in the range starting at off and continuing for len bytes are invalid for the object specified by fildes.
The mapping could not be locked in memory, because it would require more space than the system is able to supply.
len exceeds the user address space size of a c_actor.
MAP_FIXED was specified, and the address range starting at addr and continuing for len bytes exceeds that allowed for the address space of a c_actor; or MAP_FIXED was not specified and there is insufficient room in the address space to effect the mapping.
The object has a size of 0.
The mapping could not be locked in memory, due to a lack of resources.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | FEATURES | DESCRIPTION | RESTRICTION | RETURN VALUE | ERRORS | ATTRIBUTES | SEE ALSO