Unlocks a semaphore.
Standard C Library (libc.a)
int msem_unlock ( Sem, Condition)
The msem_unlock subroutine attempts to unlock a binary semaphore.
If the semaphore is currently locked, it is unlocked and the msem_unlock subroutine completes successfully.
If the Condition parameter is 0, the semaphore is unlocked, regardless of whether or not any other processes are currently attempting to lock it. If the Condition parameter is set to the MSEM_IF_WAITERS value, and another process is waiting to lock the semaphore or it cannot be reliably determined whether some process is waiting to lock the semaphore, the semaphore is unlocked by the calling process. If the Condition parameter is set to the MSEM_IF_WAITERS value and no process is waiting to lock the semaphore, the semaphore will not be unlocked and an error will be returned.
|Sem||Points to an msemaphore structure that specifies the semaphore to be unlocked.|
|Condition||Determines whether the msem_unlock subroutine unlocks the semaphore if no other processes are waiting to lock it.|
When successful, the msem_unlock subroutine returns a value of 0. Otherwise, it returns a value of -1 and sets the errno global variable to indicate the error.
If the msem_unlock
subroutine is unsuccessful, the errno global variable is set to one
of the following values:
|EAGAIN||Indicates a Condition value of MSEM_IF_WAITERS was specified and there were no waiters.|
|EINVAL||Indicates the Sem parameter points to an msemaphore structure specifying a semaphore that has been removed, or the Condition parameter is not valid.|
The msem_unlock subroutine is part of Base Operating System (BOS) Runtime.
The msem_init (msem_init Subroutine) subroutine, msem_lock (msem_lock Subroutine) subroutine, msem_remove (msem_remove Subroutine) subroutine.
List of Memory Mapping Services and Understanding Memory Mapping in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.