Documentation
¶
Overview ¶
Package ipc provides a way to use System V IPC. System V IPC includes three interprocess communication mechanisms that are widely available on UNIX systems: message queues, semaphore, and shared memory.
Index ¶
- Constants
- func Ftok(pathname string, projectid uint8) (int, error)
- func Msgget(key int, msgflg int) (int, error)
- func Msgrcv(msgid int, msgp uintptr, msgsz int, msgtyp uint, msgflg int) (int, error)
- func Msgreceive(msgid int, msgType uint, flags int) ([]byte, error)
- func Msgrm(msgid int) error
- func Msgsend(msgid int, msgType uint, msgText []byte, flags int) error
- func Msgsnd(msgid int, msgp uintptr, msgsz int, msgflg int) error
- func Semget(key int, nsems int, semflg int) (int, error)
- func Semgetvalue(semid int, semnum int) (int, error)
- func Semop(semid int, sops uintptr, nsops int) (bool, error)
- func Semoperate(semid int, sops []Sembuf) (bool, error)
- func Semp(semid int, semnum int, semflg int) (bool, error)
- func Semrm(semid int) error
- func Semsetvalue(semid int, semnum int, semun int) (bool, error)
- func Semv(semid int, semnum int, semflg int) (bool, error)
- func Shmat(shmid int, shmFlg int) (uintptr, error)
- func Shmdetach(b []byte) error
- func Shmdt(addr uintptr) error
- func Shmget(key int, size int, shmFlg int) (int, error)
- func Shmgetattach(key int, size int, shmFlg int) (int, []byte, error)
- func Shmrm(shmid int) error
- type Sembuf
Constants ¶
const ( // IPC_CREAT creates if key is nonexistent IPC_CREAT = 01000 // IPC_EXCL fails if key exists. IPC_EXCL = 02000 // IPC_NOWAIT returns error no wait. IPC_NOWAIT = 04000 // IPC_PRIVATE is private key IPC_PRIVATE = 00000 // SEM_UNDO sets up adjust on exit entry SEM_UNDO = 010000 // IPC_RMID removes identifier IPC_RMID = 0 // IPC_SET sets ipc_perm options. IPC_SET = 1 // IPC_STAT gets ipc_perm options. IPC_STAT = 2 )
Variables ¶
This section is empty.
Functions ¶
func Ftok ¶
Ftok uses the given pathname (which must refer to an existing, accessible file) and the least significant 8 bits of proj_id (which must be nonzero) to generate a key_t type System V IPC key.
func Msgreceive ¶
Msgreceive calls the msgrcv system call.
func Semget ¶
Semget calls the semget system call.
The semget() system call returns the System V semaphore set identifier associated with the argument key.
A new set of nsems semaphores is created if key has the value IPC_PRIVATE or if no existing semaphore set is associated with key and IPC_CREAT is specified in semflg.
If semflg specifies both IPC_CREAT and IPC_EXCL and a semaphore set already exists for key, then semget() fails with errno set to EEXIST.
The argument nsems can be 0 (a don't care) when a semaphore set is not being created. Otherwise, nsems must be greater than 0 and less than or equal to the maximum number of semaphores per semaphore set.
If successful, the return value will be the semaphore set identifier, otherwise, -1 is returned, with errno indicating the error.
func Semgetvalue ¶
Semgetvalue calls the semctl GETVAL system call.
func Semop ¶
Semop calls the semop system call.
semop() performs operations on selected semaphores in the set indi‐ cated by semid. Each of the nsops elements in the array pointed to by sops is a structure that specifies an operation to be performed on a single semaphore. The elements of this structure are of type struct sembuf, containing the following members:
unsigned short sem_num; /* semaphore number */ short sem_op; /* semaphore operation */ short sem_flg; /* operation flags */
Flags recognized in sem_flg are IPC_NOWAIT and SEM_UNDO. If an operation specifies SEM_UNDO, it will be automatically undone when the process terminates.
The set of operations contained in sops is performed in array order, and atomically, that is, the operations are performed either as a complete unit, or not at all. The behavior of the system call if not all operations can be performed immediately depends on the presence of the IPC_NOWAIT flag in the individual sem_flg fields, as noted be‐ low.
func Semoperate ¶
Semoperate calls the semop system call. Flags recognized in SemFlg are IPC_NOWAIT and SEM_UNDO. If an operation specifies SEM_UNDO, it will be automatically undone when the process terminates.
func Semp ¶
Semp calls the semop P system call. Flags recognized in semflg are IPC_NOWAIT and SEM_UNDO. If an operation specifies SEM_UNDO, it will be automatically undone when the process terminates.
func Semsetvalue ¶
Semsetvalue calls the semctl SETVAL system call.
func Semv ¶
Semv calls the semop V system call. Flags recognized in semflg are IPC_NOWAIT and SEM_UNDO. If an operation specifies SEM_UNDO, it will be automatically undone when the process terminates.
func Shmgetattach ¶
Shmgetattach calls the shmget and shmat system call.