.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "<sys/sem.h>" 0P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" <sys/sem.h>
.SH NAME
sys/sem.h \- XSI semaphore facility
.SH SYNOPSIS
.LP
\fB#include <sys/sem.h> \fP
.SH DESCRIPTION
.LP
The \fI<sys/sem.h>\fP header shall define the following constants
and structures.
.LP
Semaphore operation flags:
.TP 7
SEM_UNDO
Set up adjust on exit entry.
.sp
.LP
Command definitions for the \fIsemctl\fP() function shall be provided
as follows:
.TP 7
GETNCNT
Get \fIsemncnt\fP.
.TP 7
GETPID
Get \fIsempid\fP.
.TP 7
GETVAL
Get \fIsemval\fP.
.TP 7
GETALL
Get all cases of \fIsemval\fP.
.TP 7
GETZCNT
Get \fIsemzcnt\fP.
.TP 7
SETVAL
Set \fIsemval\fP.
.TP 7
SETALL
Set all cases of \fIsemval\fP.
.sp
.LP
The \fBsemid_ds\fP structure shall contain the following members:
.sp
.RS
.nf
\fBstruct ipc_perm sem_perm \fP Operation permission structure. \fB
unsigned short sem_nsems\fP Number of semaphores in set. \fB
time_t sem_otime\fP Last \fIsemop\fP
() time. \fB
time_t sem_ctime\fP Last time changed by \fIsemctl\fP
(). \fB
\fP
.fi
.RE
.LP
The \fBpid_t\fP, \fBtime_t\fP, \fBkey_t\fP, and \fBsize_t\fP types
shall be defined as described in \fI<sys/types.h>\fP .
.LP
A semaphore shall be represented by an anonymous structure containing
the following members:
.sp
.RS
.nf
\fBunsigned short semval \fP Semaphore value. \fB
pid_t sempid \fP Process ID of last operation. \fB
unsigned short semncnt \fP Number of processes waiting for \fIsemval\fP \fB
\fP to become greater than current value. \fB
unsigned short semzcnt \fP Number of processes waiting for \fIsemval\fP \fB
\fP to become 0. \fB
\fP
.fi
.RE
.LP
The \fBsembuf\fP structure shall contain the following members:
.sp
.RS
.nf
\fBunsigned short sem_num \fP Semaphore number. \fB
short sem_op \fP Semaphore operation. \fB
short sem_flg \fP Operation flags. \fB
\fP
.fi
.RE
.LP
The following shall be declared as functions and may also be defined
as macros. Function prototypes shall be provided.
.sp
.RS
.nf
\fBint semctl(int, int, int, ...);
int semget(key_t, int, int);
int semop(int, struct sembuf *, size_t);
\fP
.fi
.RE
.LP
In addition, all of the symbols from \fI<sys/ipc.h>\fP shall be defined
when
this header is included.
.LP
\fIThe following sections are informative.\fP
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fI<sys/ipc.h>\fP, \fI<sys/types.h>\fP, \fIsemctl\fP(), \fIsemget\fP(),
\fIsemop\fP()
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .
|