Guardian Programmer's Guide

Table Of Contents
Synchronizing Processes
Guardian Programmer’s Guide 421922-014
26 - 4
Summary of Guardian Binary
Semaphore Procedures
Summary of Guardian Binary
Semaphore Procedures
HP provides Guardian procedure calls to implement the binary semaphore capability.
The procedures are callable from programs written in Transaction Application
Language (TAL) and C/C++. The binary semaphore procedure calls are summarized
in Table 26-1. Refer to the Guardian Procedure Calls Reference Manual for detailed
descriptions of these procedure calls, including input and output parameters and error
status values returned by the calls.
Table 26-2. Binary Semaphore Procedure Calls
Procedure Description
BINSEM_CREATE_ Creates, opens, and locks a binary semaphore. Generally
c
alled by the program that creates the shared resource.
BINSEM_OPEN_ Opens a binary semaphore. All processes that will use the
bin
ary semaphore must first open it.
BINSEM_LOCK_ Locks a binary semaphore. Called by a process immediately
be
fore entering a critical section. Only one process at a time
can lock a binary semaphore. This enables a program to have
exclusive access to a shared resource. If a process tries to
lock a semaphore that is already locked, the process enters a
wait state.
BINSEM_UNLOCK_ Relinquishes a lock on a binary semaphore. Called by a
p
rocess immediately upon leaving a critical section. If there are
processes in the wait group, one of those processes is given
ownership of the lock.
BINSEM_CLOSE_ Closes a binary semaphore. Called by a process when it is
f
inished accessing the binary semaphore. When the last
process that has a semaphore open closes the semaphore,
that semaphore ceases to exist.
BINSEM_FORCELOCK_ Forces a lock on a binary semaphore. Used to take a lock
aw
ay from the process that has the lock and has entered an
unresponsive state (for example, an infinite loop).
BINSEM_GETSTATS_
*
* Available only for NonStop systems running J06.14, H06.25, and subsequent RVUs.
Returns counter statistics for one or more binary semaphores
for a specified process. Additionally, BINSEM_GETSTATS_
can clear counters and reset the maximum number of
contenders.
BINSEM_STAT_VERSION_
*
Accepts a version number defined in kbinsem(.h) for the
BINSEM_GETSTATS_ procedure and checks whether or not it
matches the implementation version of BINSEM_GETSTATS_.