Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sem_destroy(2)

sem_wait(2)

sem_trywait(2)

sem_post(2)

sem_open(2)

sem_close(2)

dg_psem_info(2)

sysconf(2)



sem_init(2)                    DG/UX R4.11MU05                   sem_init(2)


NAME
       sem_init - initialize an unnamed semaphore

SYNOPSIS
       #include <semaphore.h>

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

DESCRIPTION
       Use sem_init(2) to initialize the unnamed semaphore referred to by
       sem:

        sem    is a pointer to the unnamed semaphore that will be
               initialized.

        pshared
               is ignored.  This argument allows implementation-dependent
               extensions. At present DG/UX supports no extensions.

        value  is the initial value to assign to the semaphore.

       Once sem has been successfully initialized, the semaphore may be used
       in subsequent calls to sem_wait(2), sem_trywait(2), and sem_post(2).
       The semaphore remains usable until it is destroyed via a call to
       sem_destroy(2).

       Any process which can access sem or is given a copy of sem may use it
       for performing semaphore operations.

       The value specified with this call affects the availability of the
       unnamed semaphore. A successful lock operation, with sem_wait(2) or
       sem_trywait(2), decrements the value and sem_post(2) increments it.
       If the value is 0, the semaphore is unavailable.  In this case,
       sem_wait(2) blocks until the semaphore becomes available whereas
       sem_trywait(2) returns with an error. Typical initial values
       specified with sem_init(2) are 0 or 1.

       The maximum value allowed is stored in the system variable
       SEM_VALUE_MAX.  You can obtain this value by calling sysconf(2) with
       parameter _SC_SEM_VALUE_MAX.

       Unnamed semaphores are not inherited on a fork(2). A process that
       calls exec(2) or exit(2), loses its access to its unnamed semaphores.
       Unlike files, unnamed semaphores do not persist across a system
       reboot.

       Information about all of the unnamed semaphores on the system can be
       retrieved using dg_psem_info(2).


   Note
        * This routine is based on POSIX realtime extension document P1003.4
          draft 14. It is therefore subject to change.

        * Compilation of a source file using this routine requires that
          feature macro _POSIX4_DRAFT_SOURCE be defined.  This feature macro
          is not enabled by any other feature macro, nor does it enable any
          other feature macro.

        * The compiled routine must be linked to library librte.a.

RETURN VALUE
       If successful, sem_init returns 0. If unsuccessful, it returns -1 and
       sets ERRNO to one of the following:

        EFAULT Unable to access one of the parameters.

        EINVAL value exceeds SEM_VALUE_MAX.

SEE ALSO
       sem_destroy(2), sem_wait(2), sem_trywait(2), sem_post(2),
       sem_open(2), sem_close(2), dg_psem_info(2), sysconf(2).


Licensed material--property of copyright holder(s)

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