2 ==============================
4 int sem_wait(sem_t * sem);
5 int sem_trywait(sem_t * sem);
6 int sem_post(sem_t * sem);
7 int sem_getvalue(sem_t * sem, int * sval);
12 - current semaphore count, also used as a futex
19 if (atomic_decrement_if_positive(sem->count))
22 futex_wait(&sem->count, 0)
28 n = atomic_increment(sem->count);
29 // Pass the new value of sem->count
30 futex_wake(&sem->count, n + 1);
33 sem_trywait(sem_t *sem)
35 if (atomic_decrement_if_positive(sem->count)) {
42 sem_getvalue(sem_t *sem, int *sval)