Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sem_close(3)

sem_ifwait(3)

sem_post(3)

sem_wait(3)

sem_open(3)  —  Subroutines

Digital

NAME

sem_open − Open a set of binary semaphores (P1003.4/D11). 

SYNOPSIS

#include <binsem.h>

binsemset_t sem_open (
const char ∗name,
binsemset_t ∗b);

PARAMETERS

∗name Points to the pathname naming the binary semaphore set object.  Use the name argument originally supplied with the sem_mksem function. 

∗b On successful completion of the call, contains the binary semaphore set descriptor. 

DESCRIPTION

Use the sem_open function to establish the connection between a set of binary semaphores created by the sem_mksem function and a binary semaphore set descriptor. Subsequently, the calling process can reference all the binary semaphores in the set by using the binary semaphore set descriptor returned by the sem_open function and the number, based at 0, of the binary semaphore in the set. Valid binary semaphore numbers range from 0 to n−1 inclusive for a set created with n binary semaphores.  The first time a process opens a binary semaphore set, the sem_open function allocates the binary semaphore set descriptor for the set.  The individual binary semaphores are available in subsequent calls to sem_wait, sem_ifwait, and sem_post functions. The descriptor is returned by subsequent calls to the sem_open function until the connection between the binary sempahore set name and the descriptor is broken by a call to the sem_close function. 

If the binary semaphore set is already open, the states of the semaphores in the set are unchanged. 

If this is the first time the binary semaphore set is opened, the semaphores in the set are initialized to the state given the set when it was created by using the sem_mksem function. 

Otherwise, the binary semaphores in the set have the same state they had when last closed. 

RETURN VALUES

On successful completion, this function opens the binary semaphore set, returns a descriptor for the binary set, and 0.  Otherwise, the function returns −1 and sets errno to indicate the error. 

ERRORS

The sem_open function fails under the following conditions:

[EFAULT] The parameter b was not a valid address. 

[EINVAL] Operation not supported for the given name. 

[ENAMETOOLONG] The length of the null-terminated string name exceeds SEM_NAME_MAX. 

[ENOENT] The binary semaphore set does not exist. 

[ENOSPC] A resource required to open the named binary semaphore set has been exhausted.  The limit on open binary semaphore sets for this process (SEM_NSETS_MAX) has been reached.

[ENOSYS] The function sem_open is not supported by this implementation. 

[EPERM] The process lacks appropriate privileges to open the specified binary semaphore set. 

RELATED INFORMATION

Functions: sem_close(3), sem_ifwait(3), sem_post(3), sem_wait(3)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026