task_t *sem_waitq[CONFIG_SEM_WAITQLEN];
} sem_t;
+/*
+ * sem_wait() - Decrease a semaphore, waiting if necessary
+ *
+ * SYNOPSIS
+ * int sem_wait(sem_t *sem);
+ *
+ * DESCRIPTION
+ * The sem_wait() decreases the value of the semaphore pointed
+ * to by `sem'. If the semaphore cannot be immediately decreased,
+ * the calling task will be suspended and added to the semaphore's
+ * wait list. Once the semaphore gets increased by another task,
+ * all tasks waiting on the semaphore will be woken up, and the
+ * order in which the tasks will get to pass the semaphore depends
+ * on the scheduler.
+ * If sem_wait() cannot immediately increase the semaphore, it will
+ * keep trying until it succeeds, meaning that the calling task may
+ * be suspended indefinitely if no other task invokes sem_post() on
+ * the same semaphore.
+ *
+ * RETURN VALUE
+ * 0 the value of the semaphore has been successfully decreased
+ */
int sem_wait(sem_t*);
+
+/*
+ * sem_trywait() - Decrease a semaphore
+ *
+ * SYNOPSIS
+ * int sem_trywait(sem_t *sem);
+ *
+ * DESCRIPTION
+ * The sem_trywait() function will attempt to decrease the value of
+ * the semaphore pointed to by `sem'. If the semaphore cannot be
+ * decreased immediately, the function will return an error.
+ *
+ * RETURN VALUE
+ * 0 The value of the semaphore has been successfully decreased
+ * -EAGAIN The semaphore could not immediately be decreased
+ */
int sem_trywait(sem_t*);
+
+/*
+ * sem_post() - Increase a semaphore
+ *
+ * SYNOPSIS
+ * int sem_post(sem_t *sem);
+ *
+ * DESCRIPTION
+ * The sem_post() function will increase the value of the semaphore
+ * pointed to by `sem'. If the operation succeeds, sem_post() will
+ * also cause all tasks that are waiting on the semaphore to be woken
+ * up. On failure, the state of the semaphore remains unchanged.
+ *
+ * RETURN VALUE
+ * 0 The semaphore's value has been successfully increased
+ * -EOVERFLOW The operation would have caused an overflow
+ */
int sem_post(sem_t*);
+/*
+ * sem_peek() - Get the value of a semaphore
+ *
+ * SYNOPSIS
+ * int sem_peek(sem_t *sem);
+ *
+ * DESCRIPTION
+ * The sem_peek() function will obtain the value of semaphore pointed
+ * to by `sem' and return its value. The value returned will always be
+ * larger or equal to zero.
+ *
+ * RETURN VALUE
+ * * The current value of the semaphore (>= 0)
+ */
+int sem_peek(sem_t*);
+
#endif /* __SEM_H */