%semop() Function

For Windows: Not Supported

The %semop() function performs an array of semaphore operations on a set of semaphores.

Syntax

code = %semop(sem-ID, sops, num)

Parameter(s)

sem-ID

Semaphore identifier returned by a call to %semget().

sops

Array of semaphores operation. sops is a number by 3 two-dimensional arrays. Each row in the array is the equivalent of a sops structure, as defined in the UNIX system documentation. In other words, sops ( i ,1) is sem_num, sops ( i ,2) is sem_op, sops ( i ,3) is sem_flg. See the UNIX system documentation for the description of these fields.

num

Number of rows in the sops array.

 

NOTE

The elements of the sops array are integers, instead of short integers, as the regular libc.a call.

Example(s)

include dm,bp,unix.h ipc.h

include dm,bp,unix.h sem.h

include dm,bp,unix.h mode.h

* Get a set of 4 semaphores

sem-ID=semget(key, 4, ipc$creat)

if sem-ID<0 then

crt "semget error=":system(0)

stop

end

* Wait for: (1st sem >=1) and (2nd sem >=2)

dim sops(2,3)

* - Set 1st condition

sops(1,1)=0 ;* 1st sem

sops(1,2)=-1 ;* Wait until can do -1

sops(1,3)=0 ;* No flag

* - Set 2nd condition

sops(1,1)=1 ;* 2nd sem

sops(1,2)=-2 ;* Wait until can do -2

sops(1,3)=0 ;* No flag

n=semop(sem-ID, sops, 2)

if n<0 then

crt "semop error=":system(0)

stop

end

See Also

%semctl() Function, %semget() Function