basic.%semctl C Function/BASIC Program


Command basic.%semctl C Function/BASIC Program
Applicable release versions: AP/Unix, AP 6.1
Category BASIC Program (486)
Description performs semaphore control operations.

semid Semaphore id returned by a call to semget().

semnum Semaphore number in the set, when applicable (depending on "cmd").

cmd Command code (see below).

arg Dimensioned array which contains the argument (see below).

The following "cmd" are executed with respect to the semaphore specified by "semid" and "semnum":
GETVAL Returns the value of "semval".

SETVAL Sets "semval" to the value of arg.

GETPID Returns the value of "sempid".

GETNCNT Returns the value of "semncnt".

GETZCNT Returns the value of "semzcnt".

The following "cmd" apply to all semaphores in the set:
GETALL Place all the semaphore values in the dimensioned array "arg".

SETALL Set all the semaphores to the values contained in the dimensioned array "arg".

The following commands are also available:
IPC$STAT Return a dimensioned array which contains the various s fields of the Unix sempahore structures. The elements are (see the Unix Programmer's Reference guide):
1 sem_perm.uid
2 sem_perm.cid
3 sem_perm.guid
4 sem_perm.gcid
5 sem_perm.mode
6 sem_perm.seq
7 sem_perm.key
8 sem_nsems
9 sem_otime
10 sem_ctime

IPC$SET Set the values of the following members of the data structure associated to "semid" to the first three elements of the array "arg":
1 sem_perm.uid
2 sem_perm.gid
3 sem_perm.mode

IPC$RMID Removes the semaphore identifier.

Valid values for "cmd" are defined in "sem.h" and "ipc.h".
Syntax code=%semctl(semid, semnum, cmd, arg)
include dm,bp,unix.h ipc.h
include dm,bp,unix.h sem.h

* Set initial semaphore values
dim val(3)
mat val=0
%semctl( semid, 0, SETALL, val )
Related basic.cfunc