Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ shmget(2) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

intro(2)

shmbind(2)

shmctl(2)

shmop(2)

stdipc(3C)

ipcs(1)

ipcrm(1)

shmdefine(1)

memory(7)

shmget(2)  —  AT&T SYSTEM V

NAME

shmget − get shared memory segment identifier

SYNOPSIS

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>

int shmget (key, size, shmflg)
key_t key;
int size, shmflg;

DESCRIPTION

shmget returns the shared memory identifier associated with key.

A shared memory identifier and associated data structure and shared memory segment of at least size bytes [see intro(2)] are created for key if one of the following is true:

Key is equal to IPC_PRIVATE. 

Key does not already have a shared memory identifier associated with it, and (shmflg & IPC_CREAT) is “true”. 

Upon creation, the data structure associated with the new shared memory identifier is initialized as follows:

Shm_perm.cuid, shm_perm.uid, shm_perm.cgid, and shm_perm.gid are set equal to the effective user ID and effective group ID, respectively, of the calling process. 

The low-order 9 bits of shm_perm.mode are set equal to the low-order 9 bits of shmflg. Shm_segsz is set equal to the value of size.

Shm_lpid, shm_nattch, shm_atime, and shm_dtime are set equal to 0. 

Shm_ctime is set equal to the current time. 

Since the effective group ID of the calling process specifies the classification level (security label) to be associated with an object, the shared memory identifier is labeled with the user’s current level. (B1 only.) 

In addition to the access permissions, shmflg may also include one or more of the following:

­SHM_LOCAL The shared memory segment is to be loaded into the local memory of the CPU that the calling process is executing on.  If ­SHM_LOCAL is set and ­SHM_HARD is not set, then the binding of the shared memory segment is termed a "soft" binding.  A "soft" binding allows pages to be allocated from global memory when pages are not available for allocation from the local memory pool.  This flag has no effect on systems without local memory.  See memory(7). 

­SHM_HARD The shared memory segment is to be loaded into the local memory of the CPU that the calling process is executing on.  If ­SHM_HARD is set then ­SHM_LOCAL must also be set.  This binding is termed a "hard" binding.  A "hard" binding means that the calling process will receive a ­SIGSEGV signal if pages cannot be allocated from the local memory pool when needed.  This flag has no effect on systems without local memory.  See memory(7). 

­SHM_IO The shared memory segment is to be loaded into I/O memory (VERSABUS/HVMEBUS/VMEBUS).  See shmbind(2). 

­SHM_NCACHE The shared memory region will not be cached.  This option is ignored if the region is loaded into I/O memory.  Such regions are always cache-inhibited.  This option is also ignored on systems that always cache-inhibit shared memory regions. 

­SHM_COPYBACK The shared memory region will be cached in copyback mode.  By default, shared memory regions are cached in write-through mode.  This option is ignored if either the SHM_NCACHE or SHM_IO options are specified.  This option is not recommended for shared memory regions that are used for I/O purposes. 

shmget will fail if one or more of the following are true:

­[EINVAL] Size is less than the system-imposed minimum or greater than the system-imposed maximum. 

­[EACCES] A shared memory identifier exists for key, but operation permission [see intro(2)] as specified by the low-order 9 bits of shmflg would not be granted. 

­[EACCES] A shared memory identifier exists for key, but the process’s current level does not dominate the level of the shared memory. (B1 only.)

­[EINVAL] A shared memory identifier exists for key, but the size of the segment associated with it is less than size and size is not equal to zero. 

­[ENOENT] A shared memory identifier does not exist for key, and (shmflg & IPC_CREAT) is “false”. 

­[ENOSPC] A shared memory identifier is to be created, but the system-imposed limit on the maximum number of allowed shared memory identifiers system-wide would be exceeded. 

­[EINVAL] (shmflg & SHM_HARD) is “true” and (shmflg & SHM_LOCAL is “false”. 

­[ENOMEM] A shared memory identifier and associated shared memory segment are to be created, but the amount of available memory is not sufficient to fill the request. 

­[EEXIST] A shared memory identifier exists for key, but ((shmflg & IPC_CREAT) and (shmflg& IPC_EXCL)) is “true”. 

SEE ALSO

intro(2), shmbind(2), shmctl(2), shmop(2), stdipc(3C). 
ipcs(1), ipcrm(1), shmdefine(1) in the CX/UX User’s Reference Manual. 
memory(7) in the CX/UX Administrator’s Reference Manual. 

DIAGNOSTICS

Upon successful completion, a non-negative integer, namely a shared memory identifier, is returned.  Otherwise, a value of −1 is returned, and errno is set to indicate the error.

NOTES

The user must explicitly remove shared memory segments after the last reference to them has been removed. 

CX/UX Programmer’s Reference Manual

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026