Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sem(3head) [opensolaris man page]

sem.h(3HEAD)							      Headers							      sem.h(3HEAD)

NAME
sem.h, sem - semaphore facility SYNOPSIS
#include <sys/sem.h> DESCRIPTION
The <sys/sem.h> header defines the following constants and structures. Semaphore operation flags: SEM_UNDO Set up adjust on exit entry. Command definitions for the semctl() function are provided as listed below. See semctl(2). GETNCNT Get semncnt. GETPID Get sempid. GETVAL Get semval. GETALL Get all cases of semval. GETZCNT Get semzcnt. SETVAL Set semval. SETALL Set all cases of semval. The semid_ds structure contains the following members: struct ipc_perm sem_perm /* operation permission structure */ unsigned short sem_nsems /* number of semaphores in set */ time_t sem_otime /* last semop() time */ time_t sem_ctime /* last time changed by semctl() */ The pid_t, time_t, key_t, and size_t types are defined as described in <sys/types.h>. See types.h(3HEAD). A semaphore is represented by an anonymous structure containing the following members: unsigned short semval /* semaphore value */ pid_t sempid /* process ID of last operation */ unsigned short semncnt /* number of processes waiting for semval to become greater than current value */ unsigned short semzcnt /* number of processes waiting for semval to become 0 */ The sembuf structure contains the following members: unsigned short sem_num /* semaphore number */ short sem_op /* semaphore operation */ short sem_flg /* operation flags */ All of the symbols from <sys/ipc.h> are defined when this header is included. See ipc.h(3HEAD). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
semctl(2), semget(2), semop(2), ipc.h(3HEAD), types.h(3HEAD), attributes(5), standards(5) SunOS 5.11 10 Sep 2004 sem.h(3HEAD)

Check Out this Related Man Page

semid_ds(4)						     Kernel Interfaces Manual						       semid_ds(4)

NAME
semid_ds - Defines a semaphore set SYNOPSIS
#include <sys/sem.h> struct semid_ds{ struct ipc_perm sem_perm; struct sem *sem_base; u_short sem_nsems; time_t sem_otime; time_t sem_ctime; }; DESCRIPTION
The semid_ds structure defines a semaphore set associated with a semaphore ID. There is one semaphore set per semaphore ID. A semaphore set is implemented as an array of sem_nsems semaphores, with sem_base pointing to the first semaphore in the set. The IPC permissions for a semaphore set are implemented in a separate, but associated, ipc_perm structure. A semaphore set is created indirectly via the semget() call. If semget() is called with a non-existent semaphore ID, the kernel allocates a new semid_ds structure, initializes it, and returns the semaphore ID that is to be associated with the semaphore set. FIELDS
The ipc_perm structure that defines permissions for semaphore operations. See NOTES. A pointer to the first semaphore in the set. Indi- vidual semaphores are defined using the sem structure. See NOTES. The number of semaphores in the set. Each semaphore in the set is ref- erenced by a unique integer. A semaphore number is sometimes referred to as sem_num, but this is not a field carried in any of the rele- vant data structures. Semaphore numbers run sequentially from zero to sem_nsems-1. The time of the last semop() operation on the set. The time of the last semctl() operation that changed a semaphore in the set. NOTES
The sem_perm field identifies the associated ipc_perm structure that defines the permissions for operations on the semaphore set. The ipc_perm structure (from the sys/ipc.h header file) is shown here. struct ipc_perm { ushort uid; /* owner's user id */ ushort gid; /* owner's group id */ ushort cuid; /* creator's user id */ ushort cgid; /* creator's group id */ ushort mode; /* access modes */ ushort seq; /* slot usage sequence number */ key_t key; /* key */ }; The mode field is a 9-bit field that contains the permissions for semaphore operations. The first three bits identify owner permissions; the second three bits identify group permissions; and the last three bits identify other permissions. In each group, the first bit indi- cates read permission; the second bit indicates write permission; and the third bit is not used. Individual semaphores are implemented with the sem structure. The sem structure (from the sys/sem.h header file) is shown here: struct sem { u_short semval; short sempid; u_short semncnt; u_short semzcnt; }; The sem fields are defined as follows: A nonnegative integer that is the current value of the semaphore. The process ID of the last process to perform an operation on the semaphore. The number of processes that are currently suspended while waiting for an operation to increment the current semval value. The num- ber of processes that are currently suspended while waiting for semval to go to zero. RELATED INFORMATION
Functions: semctl(2), semget(2), semop(2) delim off semid_ds(4)
Man Page