Guardian Procedure Calls Reference Manual (G06.25+)

Guardian Procedure Calls (A-B)
Guardian Procedure Calls Reference Manual522629-013
2-65
BINSEM_LOCK_ Procedure
specifies the binary semaphore ID.
timeout input
INT (32):value
specifies how many hundredths of a second the procedure should wait for the
binary semaphore to become unlocked. The maximum value is 2,147,483,647. A
value of -1D causes the procedure to wait indefinitely. A value of 0D causes the
procedure to return immediately to the calling process, regardless of whether the
binary semaphore is locked.
Considerations
The lock operation and the state of the binary semaphore
If the binary semaphore is unlocked before the specified timeout has elapsed,
then the value of
status is 0 and the state of the binary semaphore becomes
locked by the calling process.
If the binary semaphore is forsaken prior to the timeout specified, then the
value of
status is 4045 and the state of the binary semaphore becomes
locked by the calling process.
If the binary semaphore is locked by another process or by the calling process
and the timeout expires, then the value of
status is 4011 and the state of the
binary semaphore remains unchanged.
Locking a binary semaphore
If the calling process terminates during the lock operation, the state of the binary
semaphore is not changed.
The same process that locks a binary semaphore should also unlock it.
A binary semaphore locked by a process that has terminated becomes forsaken.
Any process that waits on binary semaphores must account for the possibility of a
forsaken binary semaphore. The binary semaphore procedures allow for recovery
of a binary semaphore from the forsaken state to the locked state.
Applications should account for a deadlock condition. For example, a deadlock
can occur if two processes require the locks on two binary semaphores and each
process holds the lock on one of the binary semaphores. A method of avoiding
deadlock situations is to lock binary semaphores in a predetermined order.
The lock operation finishes in any order regardless of when a process requests the
lock or the process priority. So, a lower-priority process could get the lock and lock
out a higher-priority process even though the higher-priority process requests it
first.
Searching for processes waiting for a lock
Note. There are additional considerations for privileged callers.