Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

bsemfree(2)

bsemwait(2)

bsemwakeup(2)

stdipc(3C)

bsemget(2)

NAME

bsemget − get and initialize a binary semaphore

SYNOPSIS

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/bsem.h>
 bsemid = bsemget (key, binsem, bsemflg)
key_t key;
struct binsem ∗binsem;
int bsemflg;

DESCRIPTION

bsemget returns the binary semaphore identifier associated with key.

A binary semaphore is created and initialized for key if one of the following are true:

Key is equal to IPC_PRIVATE. 

Key does not already have a binary semaphore associated with it and (bsemflg & IPC_CREAT) is ”true”. 

Upon creation the binary semaphore is initialized as follows:

binsem->locked is set to 0. 

binsem->not_wanted is set to 1. 

The access mode is set to the low-order 9 bits of bsemflg.

The user ID, group ID, creator user ID, and creator group ID are set equal to the effective user ID and group ID of the calling process. 

Because the effective group ID of the calling process specifies the classification level (security label) to be associated with an object, the semaphore is labeled with the user’s current level.  (B1 only)

RETURN VALUE

Upon successful completion a binary semaphore identifier is returned.  Otherwise, a value of −1 is returned and errno is set to indicate the error. 

ERRORS

bsemget will fail if one or more of the following are true:

­[EFAULT] Binsem points outside the process’s allocated address space or is not aligned on a 4-byte boundary. 

­[ENOENT] A binary semaphore identifier does not exist for key and (bsemflg & IPC_CREAT) is ”false”. 

­[ENOSPC] A binary semaphore identifier is to be created but the system-imposed limit on the maximum number of allowed binary semaphore identifiers system wide would be exceeded. 

­[ENOMEM] Not enough memory was available to allocate internal data structures. 

­[EEXIST] A binary semaphore identifier exists for key but ( (bsemflg & IPC_CREAT) & ( bsemflg & IPC_EXCL) ) is ”true”. 

[EACCES] A binary semaphore identifier exists for key, but the process’s current level does not dominate the level of the binary semaphore. (B1 only)

SEE ALSO

bsemfree(2), bsemwait(2), bsemwakeup(2), stdipc(3C)

CX/UX Programmer’s Reference Manual

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