[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

msem_unlock Subroutine

Purpose

Unlocks a semaphore.

Library

Standard C Library (libc.a)

Syntax

#include <sys/mman.h>


int msem_unlock ( Sem Condition)
msemaphore *Sem;
int Condition;

Description

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.

Parameters

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.

Return Values

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.

Error Codes

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.

Related Information

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.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]