Oracle® Solaris 11.2 Programming Interfaces Guide

Exit Print View

Updated: July 2014
 
 

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 25 semaphores.

The POSIX semaphore interfaces are shown below.

sem_open

Connects to, and optionally creates, a named semaphore

sem_init

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

sem_close

Ends the connection to an open semaphore

sem_unlink

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

sem_destroy

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

sem_getvalue

Copies the value of the semaphore into the specified integer

sem_wait

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