OAR

RTEMS 4.5.0 On-Line Library


Semaphore Manager sem_trywait - Non-blocking Wait on a Semaphore

PREV UP NEXT Bookshelf RTEMS POSIX API User's Guide

9.4.7: sem_trywait - Non-blocking Wait on a Semaphore

CALLING SEQUENCE:

int sem_trywait(
  sem_t *sem
);

STATUS CODES:

EAGAIN
The semaphore is not available (i.e., the semaphore value is zero), so the semaphore could not be locked.
EINVAL
The sem argument does not refewr to a valid semaphore

DESCRIPTION:

This function attempts to lock a semaphore specified by sem. If the semaphore is available, then the semaphore is locked (i.e., the semaphore value is decremented) and the function returns a value of 0. The semaphore remains locked until released by a sem_post() call. If the semaphore is unavailable (i.e., the semaphore value is zero), then the function will return a value of -1 immediately and set errno to EAGAIN.

If the call is unsuccessful, then the function returns -1 and sets errno to the appropriate error code.

NOTES:

Multiprocessing is not supported in this implementation.


PREV UP NEXT Bookshelf RTEMS POSIX API User's Guide

Copyright © 1988-2000 OAR Corporation