basic.%semop
Perform semaphore operation.
Syntax
code=%semop( semid, sops, nsops )
Description
performs an array of semaphore operations on a set of semaphores.
semid Semaphore identifier returned by a call to semget().
sops Array of semaphores operation. 'sops' is a 'nsops' by 3 two-dimension array. Each row in the array is the equivalent of a 'sops' structure, as defined in the Unix Programmer Reference Guide. In other words, sops(i,1) is sem_num, sops(i,2) is sem_op, sops(i,3) is sem_flg. See the Unix documentation for the description of these fields.
nsops Number of rows in the 'sops' array.
Example
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
semid=semget( key, 4, IPC$CREAT )
if semid<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( semid, sops, 2)
if n<0 then
crt 'semop error=':system(0)
stop
end
See Also
User Comments
What do you think?
Share your experience or ask a question by using the form below.
Login to leave your comments.
