Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/syncsemwait.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/syncsemwait.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/syncsemwait.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/syncsemwait.html on line 8

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 );

Arguments:

sync
A pointer to the synchronization object for the semaphore that you want to wait on.
try
Nonzero if you want a conditional wait.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The SyncSemWait() and SyncSemWait_r() 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.

These functions are identical, except in the way they indicate errors. See the Returns section for details.


Note: Instead of using these kernel calls directly, consider calling sem_timedwait(), sem_trywait() or sem_wait().

If try is nonzero, the function 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, the function returns -1 and sets errno. Any other value returned indicates success (the semaphore was successfully decremented).
SyncSemWait_r()
Returns EOK on success (the semaphore was successfully decremented). This function does NOT set errno. If an error occurs, the function returns one of the values listed in the Errors section.

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 Neutrino

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

See also:

sem_destroy(), sem_init(), sem_post(), sem_timedwait(), sem_trywait(), sem_wait(), SyncDestroy(), SyncSemPost(), SyncTypeCreate()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/syncsemwait.html on line 193

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/syncsemwait.html on line 193