PHP Manual
Prev |  | Next

# sem_get

sem_get -- get a semaphore id

## Description

`int sem_get`(int key, int [max_acquire] , int [perm] );

Returns: A positive semaphore identifier on success, or false on error.

sem_get() returns an id that can be used to access the System V semaphore with the given key. The semaphore is created if necessary using the permission bits specified in perm (defaults to 0666). The number of processes that can acquire the semaphore simultaneously is set to max_acquire (defaults to 1). Actually this value is set only if the process finds it is the only process currently attached to the semaphore.

A second call to sem_get() for the same key will return a different semaphore identifier, but both identifiers access the same underlying semaphore.

See also: sem_acquire() and sem_release().

Prev | Home | Next
Semaphore and shared memory functions | Up | sem_acquire