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
This commit is contained in:
Rich Felker
2011-04-06 12:24:34 -04:00
parent cd3bb38412
commit a113434cd6
5 changed files with 37 additions and 21 deletions

View File

@ -3,7 +3,8 @@
int sem_post(sem_t *sem)
{
if (!a_fetch_add(sem->__val, 1))
a_inc(sem->__val);
if (sem->__val[1])
__wake(sem->__val, 1, 0);
return 0;
}