musl/src/thread/sem_post.c
Rich Felker a113434cd6 major semaphore improvements (performance and correctness)
1. make sem_[timed]wait interruptible by signals, per POSIX
2. keep a waiter count in order to avoid unnecessary futex wake syscalls
2011-04-06 12:24:34 -04:00

11 lines
158 B
C

#include <semaphore.h>
#include "pthread_impl.h"
int sem_post(sem_t *sem)
{
a_inc(sem->__val);
if (sem->__val[1])
__wake(sem->__val, 1, 0);
return 0;
}