PHP Semaphore, Shared Memory and IPC Functions

EditRocket provides the following information on Semaphore, Shared Memory and IPC functions in the PHP source code builder.

int ftok ( string $pathname , string $proj ) -

resource msg_get_queue ( int $key [, int $perms ] ) - msg_get_queue() returns an id that can be used to access the System V message queue with the given key. The first call creates the message queue with the optional perms. A second call to msg_get_queue() for the same key will return a different message queue identifier, but both identifiers access the same underlying message queue.

bool msg_receive ( resource $queue , int $desiredmsgtype , int &$msgtype , int $maxsize , mixed &$message [, bool $unserialize [, int $flags [, int &$errorcode ]]] ) - msg_receive() will receive the first message from the specified queue of the type specified by desiredmsgtype.

bool msg_remove_queue ( resource $queue ) - msg_remove_queue() destroys the message queue specified by the queue. Only use this function when all processes have finished working with the message queue and you need to release the system resources held by it.

bool msg_send ( resource $queue , int $msgtype , mixed $message [, bool $serialize [, bool $blocking [, int &$errorcode ]]] ) - msg_send() sends a message of type msgtype (which MUST be greater than 0) to the message queue specified by queue.

bool msg_set_queue ( resource $queue , array $data ) - msg_set_queue() allows you to change the values of the msg_perm.uid, msg_perm.gid, msg_perm.mode and msg_qbytes fields of the underlying message queue data structure.

array msg_stat_queue ( resource $queue ) - msg_stat_queue() returns the message queue meta data for the message queue specified by the queue. This is useful, for example, to determine which process sent the message that was just received.

bool sem_acquire ( resource $sem_identifier ) - sem_acquire() blocks (if necessary) until the semaphore can be acquired. A process attempting to acquire a semaphore which it has already acquired will block forever if acquiring the semaphore would cause its maximum number of semaphore to be exceeded.

resource sem_get ( int $key [, int $max_acquire [, int $perm [, int $auto_release ]]] ) - sem_get() returns an id that can be used to access the System V semaphore with the given key.

bool sem_release ( resource $sem_identifier ) - sem_release() releases the semaphore if it is currently acquired by the calling process, otherwise a warning is generated.

bool sem_remove ( resource $sem_identifier ) - sem_remove() removes the given semaphore.

int shm_attach ( int $key [, int $memsize [, int $perm ]] ) - shm_attach() returns an id that can be used to access the System V shared memory with the given key, the first call creates the shared memory segment with memsize and the optional perm-bits perm.

bool shm_detach ( int $shm_identifier ) -

mixed shm_get_var ( int $shm_identifier , int $variable_key ) - shm_get_var() returns the variable with a given variable_key, in the given shared memory segment. The variable is still present in the shared memory.

bool shm_put_var ( int $shm_identifier , int $variable_key , mixed $variable ) - shm_put_var() inserts or updates the variable with the given variable_key.

bool shm_remove ( int $shm_identifier ) - shm_remove() removes the shared memory shm_identifier. All data will be destroyed.

bool shm_remove_var ( int $shm_identifier , int $variable_key ) - Removes a variable with a given variable_key and frees the occupied memory.