Makes a single attempt to acquire the resource protected by a semaphore.
#include <semaphore.h> int sem_trywait ( sem_t *sem );
(IN) Points to the semaphore to acquire.
If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following values.
If the semaphore count is greater than zero, the sem_trywait function decrements the semaphore value and returns 0 to indicate a successful acquisition of the resource.
If the semaphore count is zero or less than zero, the semaphore cannot be immediately acquired. Because sem_trywait cannot block and wait for the resource to become available, the function returns EBUSY to indicate failure and does not modify the semaphore value.