Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

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

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sysconf(2)



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


NAME
       sem_init - initialize an unnamed semaphore

SYNOPSIS
       #include <semaphore.h>

       int seminit (*sem, pshared, value)
            semt          *sem;
            int            pshared;
            unsigned int   value;

DESCRIPTION
       Use seminit(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 semwait(2), semtrywait(2), and sempost(2).
       The semaphore remains usable until it is destroyed via a call to
       semdestroy(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 semwait(2) or
       semtrywait(2), decrements the value and sempost(2) increments it.
       If the value is 0, the semaphore is unavailable.  In this case,
       semwait(2) blocks until the semaphore becomes available whereas
       semtrywait(2) returns with an error. Typical initial values
       specified with seminit(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 dgpseminfo(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, seminit 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
       semdestroy(2), semwait(2), semtrywait(2), sempost(2),
       semopen(2), semclose(2), dgpseminfo(2), sysconf(2).


Licensed material--property of copyright holder(s)

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