Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sem_wait(2) — DG/UX R4.11

Media Vault

Software Library

Restoration Projects

Artifacts Sought



sem_wait(2)                       SDK R4.11                      sem_wait(2)


NAME
       sem_wait - lock a semaphore

SYNOPSIS
       #include <semaphore.h>

       int semwait (*sem)
            semt  *sem;

DESCRIPTION
       Use semwait(2) to lock a semaphore:

        sem    is a valid semaphore address returned by a prior seminit(2)
               or semopen(2) call.

       Locking a semaphore decrements its value specified with the
       seminit(2) or semopen(2) call. Unlocking a semaphore increments the
       value.

       If the semaphore is unavailable (its value is zero), semwait blocks
       until the semaphore becomes available, or a signal is received.  Once
       locked, the semaphore stays locked until it is unlocked with
       sempost(2). Thus, if your process locks a semaphore and then calls
       semclose(2), exit(2), or exec(2), the semaphore (provided it
       continues to exist) remains locked.

       A thread blocked waiting for an UNnamed semaphore, will be returned
       an error if some other process destroys the semaphore with a call to
       semdestroy(2).  A thread blocked waiting for a named semaphore, will
       continue to be blocked if another thread in its process successfully
       unlinks the semaphore with a call to semunlink(2).

       For a non-blocking lock operation (return immediately with an error
       if the semaphore is unavailable, otherwise lock it), use
       semtrywait(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, semwait returns 0. If unsuccessful, it returns -1 and
       sets ERRNO to one of the following:

        EDEADLK
               While this thread was waiting for the unnamed semaphore to
               become available, some process called semdestroy(2) and
               removed the semaphore.

        EFAULT *sem is an invalid address.

        EINTR  A signal interrupted this function.

        EINVAL sem is invalid.

        ENOSPC sem is unavailable and there is insufficient memory for
               semwait(2) to block.

SEE ALSO
       semdestroy(2), semclose(2), seminit(2), semopen(2),
       semtrywait(2), semunlink(2), semgetvalue(2), sempost(2).


Licensed material--property of copyright holder(s)

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