Open System Services Programmer's Guide

On servers running J06.12 or later J-series RVUs or H06.23 or later H-series RVUs:
Both Guardian processes and OSS processes can call the OSS shared memory functions,
which are shmat(), shmctl(), shmdt(), and shmget(). They can share segments as
described for shmget().
There is no configured limit to the number of shared memory segments or their size created
by shmget(). The size of the shared memory segment and number of shared memory segments
are limited by system resources only.
On servers running J06.11 or earlier J-series RVUs, H06.22 or earlier H-series RVUs, or G-series
RVUs:
Only OSS processes can call shmget() and related functions; Guardian process calls to
these functions fail and errno is set to the value of [ENOTOSS].
A shared memory segment created by shmget() can contain up to 128 megabytes (MB).
A process can attach no more than 13 segments at one time. If an attached segment is larger
than 32 MB the maximum number of attached segments is reduced.
The distinction between flat and selectable segments, and how to use these shared memory segments,
is discussed in detail in “Managing Memory” (page 162). Using shared memory is an efficient IPC
mechanism that can be used when large amounts of data need to be shared between an OSS
process and a Guardian process running on the same processor.
Sharing 64-Bit Memory
Beginning with the H06.24 and J06.13 RVUs, access to 64-bit memory is supported on:
64-bit OSS processes
32-bit OSS processes
Native Guardian processes
For information about sharing 64-bit memory, see “Sharing Memory Between 32-Bit and 64-Bit
Processes” (page 290).
Coordinating Memory Sharing
Shared-memory communication generally requires synchronization of critical regions, to serialize
access to and update of the shared data. OSS processes can use semaphores, via the sem*()
functions. Both OSS and Guardian processes can use Binary Semaphores, manipulated with the
BINSEM_*() procedures; see the Summary of Guardian Binary Semaphore Procedures in the
Guardian Programmer’s Guide.
Use One API to Manipulate a Memory Segment
You cannot use both OSS functions and Guardian procedures to manipulate the same memory
segment. For example, an OSS process cannot call a Guardian procedure, such as
SEGMENT_ALLOCATE_, to allocate a memory segment and then call an OSS function, such as
shmctl(), to manipulate the same segment.
Considerations for TNS Processes
HP strongly recommends that a G-series OSS TNS process use flat segments and not explicit
selectable segments, because in a C program using xmem (the large or wide model), the TNS data
heap and most global data reside in a selectable segment, and you cannot access both selectable
segments at the same time. (The data heap and global data in native processes are not in a
selectable segment.)
See Chapter 4: Managing Memory (page 162) for more information about NonStop operating
system extended data (memory) segments.
190 Interprocess Communication