shm.h

Overview

Related Modules:

MEM

Description:

Declares APIs for creating, mapping, deleting, and controlling shared memory.

Since:

1.0

Version:

1.0

Summary

Data Structures

Data Structure Name Description
shmid_ds Stores information about a shared memory segment.
shminfo Describes limitations and attributes of system-level shared memory.
shm_info Describes system resource information about the shared memory.

Macros

Macro Name and Value Description
SHMLBA   4096 Aligns the shared memory address.
SHM_R   0400 Indicates that the shared memory segment is readable. This macro is used for setting the shmflg parameter passed to functions such as shmget().
SHM_W   0200 Indicates that the shared memory segment is writable. This macro is used for setting the shmflg parameter passed to functions such as shmget().
SHM_RDONLY   010000 Indicates that the attached shared memory segment is read-only. This macro is used for setting the shmflg parameter passed to functions such as shmat().
SHM_RND   020000 Indicates that the shared memory address can be rounded to a value meeting the requirement (SHMLBA). This macro is used for setting the shmflg parameter passed to functions such as shmat().
SHM_REMAP   040000 Indicates that the memory segment can be remapped. This macro is used for setting the shmflg parameter passed to functions such as shmat().
SHM_EXEC   0100000 Indicates that the attached shared memory segment is executable. This macro is used for setting the shmflg parameter passed to functions such as shmat().
SHM_LOCK   11 Locks the shared memory segment in memory so that it cannot be swapped to the swap partition. This macro is used for setting the shmflg parameter passed to functions such as shmget().
SHM_UNLOCK   12 Unlocks the shared memory segment. This macro is used for setting the shmflg parameter passed to functions such as shmget().
SHM_STAT   (13 (IPC_STAT & 0x100))
SHM_INFO   14 Obtains a shm_info data structure that includes system resource information about this shared memory segment. This macro is used for setting the cmd parameter passed to shmctl().
SHM_STAT_ANY   (15 (IPC_STAT & 0x100))

Functions

Function Name Description
shmat (int shmid, const void shmaddr, int shmflg) void Attaches the shared memory segment identified by shmid to the address space of the current process.
shmctl (int shmid, int cmd, struct shmid_ds buf) int Performs a control operation specified by the cmd parameter on the shared memory segment identified by shmid.
shmdt (const void shmaddr) int Detaches the shared memory segment attached to the address pointed to by shmaddr from the address space of the calling process.
shmget (key_t key, size_t size, int shmflg) int Obtains or creates a shared memory segment with the specified size based on the ID specified by key.