Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sema_wait(3synch) — UnixWare 2.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

semaphore(3synch)

sema_destroy(3synch)

sema_init(3synch)

sema_post(3synch)

sema_trywait(3synch)

synch(3synch)






       sema_wait(3synch)                                  sema_wait(3synch)


       NAME
             sema_wait - acquire a semaphore

       SYNOPSIS
             cc [options] -Kthread file
             #include <synch.h>
             int sema_wait(sema_t *sema);

          Parameters
             sema    pointer to the semaphore to acquire

       DESCRIPTION
             sema_wait acquires the semaphore pointed to by sema.

             If the semaphore is available (that is, if the semaphore value
             is greater than zero), sema_wait decrements the semaphore
             value and returns to the caller.

             If the semaphore is unavailable (that is, the semaphore value
             is zero or less), sema_wait decrements the semaphore value and
             suspends execution of the calling thread until the semaphore
             becomes available to the caller.

             If a thread waiting on a semaphore is interrupted by a signal,
             the signal handler will run, but then the thread will resume
             waiting for the semaphore.  Thus, when sema_wait returns
             without an error, it will always have acquired the semaphore.

          sema Parameter
             sema must previously have been initialized, either by
             sema_init or statically (see sema_init).

          Return Values
             sema_wait returns zero for success and an error number for
             failure, as described below.

          Errors
             If any of the following conditions is detected, sema_wait
             returns the corresponding value:

             EINVAL   Invalid argument specified.

       USAGE
             See the description of semaphores under USAGE on
             sema_init(3synch).



                           Copyright 1994 Novell, Inc.               Page 1













      sema_wait(3synch)                                  sema_wait(3synch)


            In general, sema_wait is used to block wait for an event, or
            when a critical section is long.  Semaphores are
            asynchronous-safe, and may be used to communicate between
            signal handlers and base level code.

      REFERENCES
            semaphore(3synch), sema_destroy(3synch), sema_init(3synch),
            sema_post(3synch), sema_trywait(3synch), synch(3synch)








































                          Copyright 1994 Novell, Inc.               Page 2








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