Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The general steps for using a System V semaphore are the following:
Create or open a semaphore set using semget().
Initialize the semaphores in the set using the semctl() SETVAL or SETALL operation. (Only one process should do this.)
Perform operations on semaphore values using semop(). The processes using the semaphore typically use these operations to indicate acquisition and release of a shared resource.
When all processes have finished using the semaphore set, remove the set using the semctl() IPC_RMID operation. (Only one process should do this.)