Locks a semaphore, blocking for the specified time period if necessary.
#include <semaphore.h> int sem_timedwait ( sem_t *sem, const struct timespec *abstime);
(IN) Points to the semaphore to acquire.
(IN) Points to a timespec structure which specifies the maximum amount of time you are willing to wait. See timespec_t, which is also called timespec and timestrc_t.
If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following values.
If the semaphore is immediately available, the sema_timedwait function locks the semaphore and returns. If the semaphore is not immediately available, the calling thread blocks on the semaphore and waits the specified time. If the semaphore becomes available during this time, the sema_timedwait function locks the semaphore and returns. If it doesn't become available during this time, the function sets errno to ETIMEDOUT.
The time interval specified in the abstime parameter specifies the absolute time passed which you do not want to wait, such as 10 a.m. today. To enter that value in the abstime parameter, you combine the current UTC time plus the time required to get to the absolute time.