Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ waitsem(S) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

creatsem(S)

opensem(S)

sigsem(S)


 waitsem(S)                     6 January 1993                     waitsem(S)


 Name

    waitsem, nbwaitsem - awaits and checks access to a semaphore-governed
    resource

 Syntax


    cc ... -lx


    int waitsem (sem_num)
    int sem_num;

    int nbwaitsem (sem_num)
    int sem_num;


 Description

    waitsem gives the calling process access to the resource governed by the
    semaphore semnum.  If the resource is in use by another process, waitsem
    puts the process to sleep until the resource becomes available; nbwaitsem
    returns the error ENAVAIL.  waitsem and nbwaitsem are used in conjunction
    with sigsem to allow synchronization of processes wishing to access a
    resource.  One or more processes may wait on the given semaphore (using
    waitsem) and are put to sleep until the process that currently has access
    to the resource issues sigsem.  sigsem causes the next process in line on
    the semaphore's queue to be rescheduled for execution.  The semaphore's
    queue is organized in first in first out FIFO order.

 System compatibility

    waitsem can only be used to synchronize semaphores created under UNIX
    Version 3, not for UNIX System V semaphores.

 Diagnostics

    waitsem returns the value (int) -1 if an error occurs.  If semnum has
    not been previously opened by a call to opensem or creatsem, errno is set
    to EBADF.  If semnum does not refer to a semaphore type file, errno is
    set to ENOTNAM.  All processes waiting (or attempting to wait) on the
    semaphore return with errno set to ENAVAIL when the process controlling
    the semaphore exits without relinquishing control (thereby leaving the
    resource in an undeterminate state).  If a process does two calls to
    waitsem in a row without doing an intervening sigsem, errno is set to
    EINVAL.

 Notes

    This feature is a XENIX specific enhancement and may not be present in
    all UNIX implementations.  This routine must be linked with the linker
    option -lx.

 See also

    creatsem(S), opensem(S), sigsem(S)

 Standards conformance

    waitsem and nbwaitsem are not part of any currently supported standard;
    they are an extension of AT&T System V provided by the Santa Cruz Opera-
    tion.


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