Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sem_post(3R) — SunOS 5.6

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sched_setscheduler(3R)

sem_wait(3R)

semaphore(3T)

attributes(5)

standards(5)

sem_post(3R)

NAME

sem_post − increment the count of a semaphore

SYNOPSIS

cc [ flag ... ] file ... −lposix4 [ library ... ]

#include <semaphore.h>

int sem_post(sem_t ∗sem); If prior to the call to sem_post() the value of sem was 0 and other processes (or LWPs or threads) were blocked waiting for the semaphore, then one of them will be allowed to return successfully from its call to sem_wait(3R).  The process to be unblocked will be chosen in a manner appropriate to the scheduling policies and parameters in effect for the blocked processes.  In the case of the policies SCHED_FIFO and SCHED_RR, the highest priority waiting process is unblocked, and if there is more than one highest-priority process blocked waiting for the semaphore, then the highest priority process which has been waiting the longest is unblocked. 

If, prior to the call to sem_post(), no other processes (or LWPs or thread) were blocked for the semaphore, then its value is incremented by one. 

The sem_post() function is reentrant with respect to signals (ASYNC-SAFE), and may be invoked from a signal-catching function.  The semaphore functionality described on this man page is for the POSIX (see standards(5)) threads implementation.  For the documentation of the Solaris threads interface, see semaphore(3T)). 

RETURN VALUES

If successful, sem_post() returns 0; otherwise it returns −1, and sets errno to indicate the error condition. 

ERRORS

EINVAL sem does not refer to a valid semaphore. 

ENOSYS sem_post() is not supported by this implementation. 

EXAMPLES

(see sem_wait(3R))

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
MT-Level Async-Signal-Safe

SEE ALSO

sched_setscheduler(3R), sem_wait(3R), semaphore(3T), attributes(5), standards(5)

NOTES

The sem_wait(3R) and sem_trywait(3R) functions decrement the semaphore upon their successful return. 

BUGS

In Solaris 2.5, these functions always return −1 and set errno to ENOSYS, because this release does not support the Semaphores option.  It is our intention to provide support for these interfaces in future releases. 

SunOS 5.6  —  Last change: 30 Dec 1996

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026