Synopsis:
sem_test(sem_id)
Arguments:
sem_id - The semaphore ID.
Description: The first task that calls this function will cause the value of the specified semaphore (sem_id) to be set and the function will return 1 to indicate that the calling task sucessfully caused the semaphore to be set. If the semaphore had already been set by another task then the semaphore will remain unchanged and the return value form the function will be 0.
This allows for a quick check of the status of a semaphore to be carried out, but does not provide any kind of waiting or queuing mechanism. To wait in a queue for a semaphore to be released then the sem_set() function should be used.
Returns: 1 if the semaphore was successfully set by the calling task, 0 if another task has already set the semaphore, -1 if an invalid semaphore ID is specified.