RTEMS Logo

RTEMS 4.7.2 On-Line Library


Semaphore Manager sem_timedwait - Wait on a Semaphore for a Specified Time

PREV UP NEXT Bookshelf RTEMS POSIX API User's Guide

9.4.8: sem_timedwait - Wait on a Semaphore for a Specified Time

CALLING SEQUENCE:

int sem_timedwait(
  sem_t                 *sem,
  const struct timespec *timeout
);

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 attemtps to lock a semaphore specified by sem, and will wait for the semaphore for an interval specified by timeout. 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, then the function will wait for the semaphore to become available for the amount of time specified by timeout.

If the semaphore does not become available within the interval specified by timeout, then the function returns -1 and sets errno to EAGAIN. If any other error occurs, 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-2004 OAR Corporation