[Previous] [Contents] [Next]

SyncSemWait(), SyncSemWait_r()

Wait on a semaphore

Synopsis:

#include <sys/neutrino.h>

int SyncSemWait( sync_t* sync, 
                 int try );

int SyncSemWait_r( sync_t* sync, 
                   int try );

Library:

libc

Description:

The SyncSemWait() and SyncSemWait_r() functions are identical except in the way they indicate errors. See the Returns section for details.

These kernel calls decrement the semaphore referred to by the sync argument. If the semaphore value isn't greater than zero and try is zero, then the calling process blocks until it can decrement the counter or the call is interrupted by signal.

If try is nonzero then it acts as a conditional wait. If the call would block, the semaphore is unmodified and the call returns with an error.

Returns:

The only difference between these functions is the way they indicate errors:

SyncSemWait()
If an error occurs, -1 is returned and errno is set. Any other value returned indicates success (the semaphore was successfully decremented).
SyncSemWait_r()
EOK is returned on success (the semaphore was successfully decremented). This function does NOT set errno. If an error occurs, any value in the Errors section may be returned.

Errors:

EAGAIN
Call would have blocked and try was nonzero.
EDEADLK
A deadlock condition was detected.
EINTR
A signal interrupted this function.
EINVAL
The sync argument doesn't refer to a valid semaphore.

Classification:

QNX 6

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

sem_destroy(), sem_init(), sem_post(), sem_trywait(), sem_wait(), SyncDestroy()


[Previous] [Contents] [Next]