__map_init() — Designate a storage area for mapping blocks

Standards

Standards / Extensions C or C++ Dependencies
  both

POSIX(ON)
OS/390 V2R9

Format

#define _OPEN_SYS_MAP_EXTENTION
#include <sys/mman.h>

int __map_init(struct _Mmg_init *parmlist);

General description

The __map_init() function allocates a map area in the private area of the calling address space. This map area is propagated to child address spaces on fork, which is the only way that multiple processes can share a map area. The application can connect and disconnect blocks of storage in the map area, providing a very fast way to connect up to persistent memory. The __map_init() function is meant to be used by applications which need more shared memory or mmap storage than will fit in the address space.

The application should set the following values in the _Mmg_init structure:
Element
Description
_Mmg_numblks
Set to the number of blocks to be contained in the map area.
_Mmg_megsperblk
Set to the size in megabytes of each block in the map area.
_Mmg_token
Set to an 8 character map token when successful. This map token should be saved and must be used as a parameter on calls to the __map_service() function calls.
_Mmg_res01a
Reserved, set to 0.
_Mmg_res01b
Reserved, set to 0.
_Mmg_areaaddr
As input, set to 0 if you want the address assigned or set to the address of storage where you want the map to begin. As output, this field contains the actual address of the map area.

Usage notes

  • It is intended that the application call the __map_init() service once to create the map area.
  • The application then issues fork to create child processes which will inherit a map area initialized to the hidden state.
  • The initial process or the child (and grandchildren) process can then use the __map_service to connect and disconnect blocks of storage which are persistent until explicitly deleted.
  • When the process which created the initial map area terminates, all further activity against the map blocks is terminated. The map blocks are then deleted when the last child process with an active map area terminates.
  • There is no explicit call to delete the map area. This is unlike shared memory or other IPC constructs.

Returned value

If successful, __map_init() returns NULL.

If unsuccessful, __map_init() returns -1 and sets errno to one of the following values:
Error Code
Description
EEXIST
An attempt was made to create more than one map for the process.
EFAULT
The parmlist (_Mmg_init structure) has an argument that is not accessible to the caller.
EINVAL
One of the following occurred:
  • The number of blocks (_Mmg_numblks) was zero or negative.
  • The number of megabytes per block (_Mmg_Megsperblk) was zero or negative.
  • A reserved field contained nonzero data.
  • The specified address (_Mmg_areaaddr) is not on a megabyte multiple.
EMVSSAF2ERR
An error occurred in the security product. Use the __errno2() function to retrieve the reason code to determine the exact reason the error occurred.
ENOMEM
The requested storage at location _Mmg_areaaddr or the size requested could not be obtained. The storage is either not available or your Region size is too small to contain the map area. Or, there is insufficient free virtual storage in the address space to satisfy the request.
EPERM
The user is not authorized to use the __map_init() function. Callers must be permitted to the BPX.MAP FACILITY class profile to use this service.

Related information