diff options
Diffstat (limited to 'src/thread/sem_trywait.c')
-rw-r--r-- | src/thread/sem_trywait.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/thread/sem_trywait.c b/src/thread/sem_trywait.c index 55d90075..04edf46b 100644 --- a/src/thread/sem_trywait.c +++ b/src/thread/sem_trywait.c @@ -3,8 +3,8 @@ int sem_trywait(sem_t *sem) { - int val = sem->__val[0]; - if (val>0) { + int val; + while ((val=sem->__val[0]) > 0) { int new = val-1-(val==1 && sem->__val[1]); if (a_cas(sem->__val, val, new)==val) return 0; } |