System Interface Guide

POSIX Semaphores

POSIX semaphores are much lighter weight than are System V semaphores. A POSIX semaphore structure defines a single semaphore, not an array of up to twenty five semaphores.

The POSIX semaphore interfaces are

sem_open(3R)

Connects to, and optionally creates, a named semaphore; 

sem_init(3R)

Initializes a semaphore structure (internal to the calling program, so not a named semaphore). 

sem_close(3R)

Ends the connection to an open semaphore. 

sem_unlink(3R)

Ends the connection to an open semaphore and causes the semaphore to be removed when the last process closes it. 

sem_destroy(3R)

Initializes a semaphore structure (internal to the calling program, so not a named semaphore). 

sem_getvalue(3R)

Copies the value of the semaphore into the specified integer. 

sem_wait(3R), sem_trywait(3R)

Blocks while the semaphore is held by other processes or returns an error if the semaphore is held by another process. 

sem_post(3R)

Increments the count of the semaphore.