basic.%semctl

C Function/BASIC Program, Releases: AP/Unix and AP 6.1

Performs semaphore control operations.

Syntax

code=%semctl(semid, semnum, cmd, arg)

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'.

Example

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 )

See Also

Command Name Type Description
basic.cfunc Definition can be called from a Pick/BASIC program or subroutine in AP/DOS and AP/Unix implementations using a syntax similar to that of normal C.
basic.cfunction Definition Declare a list of C functions.
basic.%semop C Function Perform semaphore operation.
basic.%semget C Function Creates a semaphore set.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.