Guardian Procedure Calls Reference Manual
Considerations
NOTE: There are additional considerations for privileged callers.
• 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 before 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 must 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
Call PROCESS_GETINFOLIST_ with the process list attribute (attribute code 15, bit <7>) to
determine whether a process is on the binary semaphore list waiting to lock a binary
semaphore.
NOTE: This information is applicable only for G-series RVUs.
• For more information about binary semaphores, see General Considerations for Binary
Semaphores (page 89).
Example
status := BINSEM_LOCK_( semid, timeout );
100 Guardian Procedure Calls (A-B)