Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

msem_unlock(3) [osf1 man page]

msem_unlock(3)						     Library Functions Manual						    msem_unlock(3)

NAME
msem_unlock - Unlocks a semaphore LIBRARY
Standard C Library (libc.a) SYNOPSIS
#include <sys/mman.h> int msem_unlock ( msemaphore *sem, int condition ); PARAMETERS
Points to an msemaphore structure which specifies the semaphore to be unlocked. Determines whether the msem_unlock() function unlocks the semaphore if no other processes are waiting to lock it. DESCRIPTION
The msem_unlock() function unlocks a binary semaphore. If the condition parameter is 0 (zero), the semaphore is unlocked, whether or not any other processes are currently attempting to lock it. If the condition parameter is MSEM_IF_WAITERS, 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 MSEM_IF_WAITERS, and no process is waiting to lock the semaphore, the semaphore will not be unlocked and an error will be returned. All calls to the msem_lock() and msem_unlock() functions by multiple processes sharing a common msemaphore structure behave as if the calls were serialized. If the msemaphore structure contains any value not resulting from a call to the msem_init() function followed by a (possibly empty) sequence of calls to the msem_lock() and msem_unlock() functions, the results are undefined. The address of an msemaphore structure may be significant. If the msemaphore structure contains any value copied from an msemaphore structure at a different address, the result is undefined. NOTES
Trial use RETURN VALUES
On successful completion, the msem_unlock() function returns 0 (zero). On error, the msem_unlock() function returns -1 and sets errno to indicate the error. ERRORS
If the msem_unlock() function fails, errno may be set to one of the following values: MSEM_IF_WAITERS was specified and there were no wait- ers. The sem parameter points to an msemaphore structure which specifies a semaphore which has been removed, or the condition parameter is invalid. RELATED INFORMATION
Functions: msem_init(3), msem_lock(3), msem_remove(3) delim off msem_unlock(3)

Check Out this Related Man Page

sem_post(3)						     Library Functions Manual						       sem_post(3)

NAME
sem_post - Unlocks a semaphore (P1003.1b) LIBRARY
Realtime Library (librt.so, librt.a) SYNOPSIS
#include <semaphore.h> int sem_post ( sem_t *sem); PARAMETERS
sem Pointer to the semaphore to be unlocked. DESCRIPTION
The sem_post function unlocks the specified semaphore by performing the semaphore unlock operation on that semaphore. The appropriate func- tion (sem_open for named semaphores or sem_init for unnamed semaphores) must be called for a semaphore before you can call the locking and unlocking functions, sem_wait, sem_trywait, and sem_post. If the semaphore value after a sem_post function is positive, no processes were blocked waiting for the semaphore to be unlocked; the sema- phore value is incremented. If the semaphore value after a sem_post function is zero, one of the processes blocked waiting for the sema- phore is allowed to return successfully from its call to sem_wait. If more than one process is blocked while waiting for the semaphore, only one process is unblocked and the state of the semaphore remains unchanged when the sem_post function returns. The process to be unblocked is selected according to the scheduling policies and priorities of all blocked processes. If the scheduling policy is SCHED_FIFO or SCHED_RR, the highest-priority waiting process is unblocked. If more than one process of that priority is blocked, then the process that has waited the longest is unblocked. The sem_post function can be called from a signal-catching function. RETURN VALUES
On successful completion, the sem_post function returns the value 0 (zero) and performs a semaphore unlock operation, unblocking a process. Otherwise, the function returns the value -1 and sets errno to indicate the error. The state of the semaphore remains unchanged. ERRORS
The sem_post function fails under the following condition: [EINVAL] The sem does not refer to a valid semaphore. RELATED INFORMATION
Functions: sem_trywait(3), sem_wait(3) Guide to Realtime Programming delim off sem_post(3)
Man Page