[ Previous ] [ Contents ] [ Index ] [ Next ]

Ns_WaitForSemaphore

Overview

Wait for a semaphore count to be greater than zero.

Syntax

    int Ns_WaitForSemaphore(
    Ns_Semaphore * sema
    );

Description

If the semaphore count is greater than zero, decrement it and continue. Otherwise, block until this is possible.

Ns_SemaWait is the preferred function for waiting for a semaphore.

Examples

    static Ns_Semaphore sem;
    
    void
Init(void) { Ns_InitializeSemaphore(&sem, 0); } void Waiter(void) { Ns_WaitForSemaphore(&sem); ... access resource ... } void Releaser(void) { Ns_ReleaseSemaphore(&sem, 1); }

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1998-99 America Online, Inc.