| iMatix home page
| << | < | > | >>
SMT Logo SMT
Version 2.81

 

semaph_wait

#include "smtlib.h"
int
semaph_wait (
    SEMAPH *semaph                      /*  Semaph to wait for               */
)

Synopsis

When the semaphore value is > 0, subtracts 1 from the semaphore value. If necessary, suspends the thread until this happens. Threads are re-started on a FIFO basis. Call as last statement in an action module. Returns 0 when completed normally, else returns -1 and sets smt_errno to one of these values:
SMT NOTREADY smt_init() was not called, or failed

Source Code - (smtlib.c)

{
#if (defined (SMT_TRACE))
    trace ("semaph_wait");
#endif
    ASSERT (semaph);
    if (!smt_alive)                     /*  If SMT API was not correctly     */
      {                                 /*    initialised, forget it         */
        smt_errno = SMT_NOTREADY;
        return (-1);
      }

    if (semaph-> value > 0)             /*  If semaphore is > 0              */
        semaph-> value--;               /*    then we can continue           */
    else
      {                                 /*  Else break on semaphore          */
        break_wanted = BREAK_WAIT_SEMAPH;
        break_semaph = semaph;
      }
    return (0);
}

| << | < | > | >> iMatix Copyright © 1996-99 iMatix Corporation