Documentation ¶
Overview ¶
Package shm implements System V shared memory functions (shmctl, shmget, shmat, shmdt).
Index ¶
- Constants
- func At(shmId int, shmAddr uintptr, shmFlg int) (data []byte, err error)
- func Ctl(shmId int, cmd int, buf *IdDs) (int, error)
- func Dt(data []byte) error
- func Get(key int, size int, shmFlg int) (shmId int, err error)
- func Rm(shmId int) error
- func Size(shmId int) (int64, error)
- type IdDs
- type Perm
Constants ¶
const ( // Create key if key does not exist. IPC_CREAT = 01000 // Fail if key exists. IPC_EXCL = 02000 // Return error on wait. IPC_NOWAIT = 04000 // Private key. IPC_PRIVATE = 0 // Attach read-only access. SHM_RDONLY = 010000 // Round attach address to SHMLBA. SHM_RND = 020000 // Take-over region on attach. SHM_REMAP = 040000 // Execution access. SHM_EXEC = 0100000 // Lock segment (root only). SHM_LOCK = 1 // Unlock segment (root only). SHM_UNLOCK = 12 // Remove identifier. IPC_RMID = 0 // Set `ipc_perm` options. IPC_SET = 1 // Get `ipc_perm' options. IPC_STAT = 2 )
Constants.
Variables ¶
This section is empty.
Functions ¶
func At ¶
At attaches the shared memory segment identified by shmId.
Using At() with shmAddr equal to NULL is the preferred, portable way of attaching a shared memory segment.
func Ctl ¶
Ctl performs the control operation specified by cmd on the shared memory segment whose identifier is given in shmId.
The buf argument is a pointer to a IdDs structure.
func Dt ¶
Dt detaches the shared memory segment.
The to-be-detached segment must be currently attached with shmAddr equal to the value returned by the attaching At() call.
func Get ¶
Get allocates a shared memory segment.
Get() returns the identifier of the shared memory segment associated with the value of the argument key. A new shared memory segment is created if key has the value IPC_PRIVATE or key isn't IPC_PRIVATE, no shared memory segment corresponding to key exists, and IPC_CREAT is specified in shmFlg.
If shmFlg specifies both IPC_CREAT and IPC_EXCL and a shared memory segment already exists for key, then Get() fails with errno set to EEXIST.
Types ¶
type IdDs ¶
type IdDs struct { // Operation permission struct. Perm Perm // Size of segment in bytes. SegSz uint64 // Last attach time. Atime int64 // Last detach time. Dtime int64 // Last change time. Ctime int64 // Pid of creator. Cpid int32 // Pid of last shmat/shmdt. Lpid int32 // Number of current attaches. Nattch uint64 // Reserved. GlibcReserved4 uint64 // Reserved. GlibcReserved5 uint64 }
IdDs describes shared memory segment.
type Perm ¶
type Perm struct { // Key. Key int32 // Owner's user ID. Uid uint32 // Owner's group ID. Gid uint32 // Creator's user ID. Cuid uint32 // Creator's group ID. Cgid uint32 // Read/write permission. Mode uint16 // Padding. Pad1 uint16 // Sequence number. Seq uint16 // Padding. Pad2 uint16 // Padding. PadCgo0 [4]byte // Reserved. GlibcReserved1 uint64 // Reserved. GlibcReserved2 uint64 }
Perm is used to pass permission information to IPC operations.