sys_sem.h(7POSIX)
π sys_sem.h β the XSI semaphore facility, bestie edition π
okay so before we even get into it: this is a page from the POSIX Programmer's Manual. Heads up though β the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the actual Linux tea β), or the interface might not even be implemented on Linux at all. π
β¨ PROLOG β¨
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
πΈ NAME πΈ
sys/sem.h β the XSI semaphore facility. yeah. semaphores. the whole vibe. π
π¦ SYNOPSIS π¦
#include <sys/sem.h>
that's it. that's the whole synopsis. one include. iconic behavior honestly. β¨
π DESCRIPTION π
okay so the <sys/sem.h> header shall define a bunch of stuff, and we're gonna go through literally all of it, no skipping, because every single one matters. π«Ά
π the semaphore operation flag
The <sys/sem.h> header shall define this symbolic constant for use as a semaphore operation flag:
SEM_UNDOβ set up adjust on exit entry.
β the semctl() command constants
The <sys/sem.h> header shall define these symbolic constants for use as commands for the semctl() function:
GETNCNTβ getsemncnt.GETPIDβ getsempid.GETVALβ getsemval.GETALLβ get all cases ofsemval.GETZCNTβ getsemzcnt.SETVALβ setsemval.SETALLβ set all cases ofsemval.
seven of them. count 'em. slay. π₯
π the semid_ds structure
The <sys/sem.h> header shall define the semid_ds structure, and bestie it shall include these 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, size_t, and time_t types
The <sys/sem.h> header shall define the pid_t, size_t, and time_t types as described in <sys/types.h>.
π the anonymous semaphore structure
A semaphore shall be represented by an anonymous structure, which shall include 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.
not me getting emotional over semzcnt waiting for semval to become 0 π the dedication. the loyalty.
π the sembuf structure
The <sys/sem.h> header shall define the sembuf structure, which shall include the following members:
unsigned short sem_num Semaphore number.
short sem_op Semaphore operation.
short sem_flg Operation flags.
π the functions
The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.
int semctl(int, int, int, ...);
int semget(key_t, int, int);
int semop(int, struct sembuf *, size_t);
three little icons. main character energy fr fr. π
π and one more include
In addition, the <sys/sem.h> header shall include the <sys/ipc.h> header.
psst β the following sections are informative. iykyk.
π APPLICATION USAGE π
None.
(genuinely nothing. the void. the silence. we love a minimal queen. β¨)
πΈ RATIONALE πΈ
None.
π¦ FUTURE DIRECTIONS π¦
None.
β SEE ALSO β
<sys_ipc.h>,<sys_types.h>- The System Interfaces volume of POSIX.1β2017,
semctl(),semget(),semop()
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 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 .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
okay that's the whole page bestie, go forth and semaphore responsibly π«Άβ¨
mwah π this lil rewrite brought to you by IEEE/The Open Group, dated 2017 β the original sys_sem.h(7POSIX) era, and honestly? they ate. ππ
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms