Shared memory is provided for the C library functions (see the manual "Executive Macros" [10 (Related publications)]).Shared memory segments are created by the shmget()
function; it is allocated in units of 1 Mbyte in the upper address space and is aligned on a 1-Mbyte boundary. The size argument of the shmget()
function is rounded accordingly.
shmget()
returns an identifier for the shared memory called the shared memory ID; shmat()
attaches the shared memory segment.
Shared memory segments are detached upon successful completion of a call to shmdt
or at program termination. The associated shared memory ID is removed:
by
shmctl()
when the last process using the shared memory has detached itself with
shmdt()
at program completion.
It is only then that the same shared memory ID may be reused.
A maximum of 150 IDs are available in BS2000 for shared memory. Up to 32 calls to the shmat()
function are allowed per program.
Note that in order to enable shared memory locking with the SHM_LOCK
control option of the shmctl()
function, the RESIDENT-PAGES
operand must be specified at /START-PROGRAM
.