Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sem_init(3R) — SunOS 5.6

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sem_destroy(3R)

sem_post(3R)

sem_wait(3R)

attributes(5)

sem_init(3R)

NAME

sem_init − initialize an unnamed semaphore

SYNOPSIS

cc [ flag ... ] file ... −lposix4 [ library ... ]

#include <semaphore.h>

int sem_init(sem_t ∗sem, int pshared, unsigned int value );

DESCRIPTION

The sem_init() function is used to initialize the unnamed semaphore referred to by sem to value. This semaphore may be used in subsequent calls to sem_wait(3R), sem_trywait(3R), sem_post(3R), and sem_destroy(3R).  This semaphore remains usable until the semaphore is destroyed. 

If pshared is non-zero, then the semaphore is sharable between processes.  If the semaphore is not being shared between processes, the application should set pshared to 0. 

RETURN VALUES

If successful, sem_init() returns 0 and initializes the semaphore in sem; otherwise it returns −1 and sets errno to indicate the error condition. 

ERRORS

EINVAL The value argument exceeds SEM_VALUE_MAX. 

ENOSPC A resource required to initialize the semaphore has been exhausted, or the resources have reached the limit on semaphores (SEM_NSEMS_MAX). 

ENOSYS The sem_init() function is not supported. 

EPERM The calling process lacks the appropriate privileges to initialize the semaphore. 

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
MT-Level MT-Safe

SEE ALSO

sem_destroy(3R), sem_post(3R), sem_wait(3R), attributes(5)

SunOS 5.6  —  Last change: 30 Dec 1996

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