#include <sys/sem.h>

sys/sem.h

$NetBSD: sem.h,v 1.5 1994/06/29 06:45:15 cgd Exp $
11 macros · 4 functions · 3 structs · 1 union · 1 typedef

macrosemid_ds

#define semid_ds __semid_ds_new

struct__semid_ds_new

size 72, align 4
struct ipc_permsem_perm[XSI] operation permission struct
__int32_tsem_base32 bit base ptr for semaphore set
unsigned shortsem_nsems[XSI] number of sems in set
time_tsem_otime[XSI] last operation time
__int32_tsem_pad1RESERVED: DO NOT USE!
time_tsem_ctime[XSI] last change time
__int32_tsem_pad2Times measured in secs since 00:00:00 GMT, Jan. 1, 1970 RESERVED: DO NOT USE!
__int32_t[4]sem_pad3RESERVED: DO NOT USE!

macroGETNCNT

Possible values for the third argument to semctl()
#define GETNCNT 3
[XSI] Return the value of semncnt {READ}

macroGETPID

#define GETPID 4
[XSI] Return the value of sempid {READ}

macroGETVAL

#define GETVAL 5
[XSI] Return the value of semval {READ}

macroGETALL

#define GETALL 6
[XSI] Return semvals into arg.array {READ}

macroGETZCNT

#define GETZCNT 7
[XSI] Return the value of semzcnt {READ}

macroSETVAL

#define SETVAL 8
[XSI] Set the value of semval to arg.val {ALTER}

macroSETALL

#define SETALL 9
[XSI] Set semvals from arg.array {ALTER}

structsem

A semaphore; this is an anonymous structure, not for external use
size 12, align 4
unsigned shortsemvalsemaphore value
pid_tsempidpid of last operation
unsigned shortsemncnt# awaiting semval > cval
unsigned shortsemzcnt# awaiting semval == 0

structsembuf

Structure of array element for second argument to semop()
size 6, align 2
unsigned shortsem_num[XSI] semaphore #
shortsem_op[XSI] semaphore operation
shortsem_flg[XSI] operation flags

macroSEM_UNDO

Possible flag values for sem_flg
#define SEM_UNDO 010000
[XSI] Set up adjust on exit entry

unionsemun

Union used as the fourth argment to semctl() in all cases. Specific member values are used for different values of the third parameter: Command Member ------------------------------------------- ------ GETALL, SETALL array SETVAL val IPC_STAT, IPC_SET buf The union definition is intended to be defined by the user application in conforming applications; it is provided here for two reasons: 1) Historical source compatability for non-conforming applications expecting this header to declare the union type on their behalf 2) Documentation; specifically, 64 bit applications that do not pass this structure for 'val', or, alternately, a 64 bit type, will not function correctly
size 8, align 8
intvalvalue for SETVAL
struct __semid_ds_new *bufbuffer for IPC_STAT & IPC_SET
unsigned short *arrayarray for GETALL & SETALL

typedefsemun_t

typedef union semun semun_t

macroSEM_A

Permissions
#define SEM_A 0200
alter permission

macroSEM_R

#define SEM_R 0400
read permission

functionsemsys

int semsys(int, ...)

functionsemctl

__DARWIN_ALIAS(semctl)
int semctl(int, int, int, ...)
man page · September 12, 1995
semctl(2) — control operations on a semaphore set

functionsemget

int semget(key_t, int, int)
man page · September 12, 1995
semget(2) — obtain a semaphore id

functionsemop

int semop(int, struct sembuf *, size_t)
man page · September 22, 1995
semop(2) — atomic array of operations on a semaphore set