[Overview][Constants][Types][Procedures and functions][Index] Reference for unit 'ipc' (#rtl)


Perform semaphore operation.


Source position: ipc.pp line 873

function semop(

  semid: cint;

  sops: PSEMbuf;

  nsops: cuint



semop performs a set of operations on a message queue. sops points to an array of type TSEMbuf. The array should contain nsops elements.

The fields of the TSEMbuf structure

TSEMbuf = record
    sem_num : word;
    sem_op  : integer;
    sem_flg : integer;

should be filled as follows:

The number of the semaphore in the set on which the operation must be performed.
The operation to be performed. The operation depends on the sign of sem_op: A positive number is simply added to the current value of the semaphore. If 0 (zero) is specified, then the process is suspended until the specified semaphore reaches zero. If a negative number is specified, it is subtracted from the current value of the semaphore. If the value would become negative then the process is suspended until the value becomes big enough, unless IPC_NOWAIT is specified in the sem_flg.
Optional flags: if IPC_NOWAIT is specified, then the calling process will never be suspended.

The function returns True if the operations were successful, False otherwise.


In case of error, False is returned, and IPCerror is set.

See also



Return the ID of a semaphore set, possibly creating the set



Perform various control operations on a semaphore set

Documentation generated on: May 14 2021