Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sem_init(3R) — SunOS 5.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sem_destroy(3R)

sem_post(3R)

sem_wait(3R)

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 );

typedef struct {
 ...
} sem_t; /∗opaque POSIX.4 semaphore∗/

MT-LEVEL

MT-Safe

DESCRIPTION

sem_init() 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 value exceeds SEM_VALUE_MAX. 

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

ENOSYS sem_init() is not supported by this implementation. 

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

SEE ALSO

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

BUGS

In Solaris 2.4, these functions always return −1 and set errno to ENOSYS, because this release does not support the Semaphores option.  It is our intention to provide support for these interfaces in future releases. 

SunOS 5.4  —  Last change: 20 Aug 1993

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