/* Lock a semaphore if not taken. 
See IEEE 1003.1  */
int sem_trywait(sem_t *semaphore)
/* Lock a semaphore if not taken. 
See IEEE 1003.1  */
int sem_trywait(sem_t *semaphore)
{
	if (k_sem_take(semaphore, K_NO_WAIT) == -EBUSY) {
		errno = EAGAIN;
		return -1;
	} else {
		return 0;
	}
}