Browse Source

fix excessive/insufficient wakes in __vm_unlock

there is no need to send a wake when the lock count does not hit zero,
but when it does, all waiters must be woken (since all with the same
sign are eligible to obtain the lock).
rs-1.0
Rich Felker 15 years ago
parent
commit
de543b05c8
  1. 6
      src/thread/pthread_barrier_wait.c

6
src/thread/pthread_barrier_wait.c

@ -13,9 +13,9 @@ void __vm_lock(int inc)
void __vm_unlock(void) void __vm_unlock(void)
{ {
if (vmlock[0]>0) a_dec(vmlock); int inc = vmlock[0]>0 ? -1 : 1;
else a_inc(vmlock); if (a_fetch_add(vmlock, inc)==-inc && vmlock[1])
if (vmlock[1]) __wake(vmlock, 1, 1); __wake(vmlock, -1, 1);
} }
static int pshared_barrier_wait(pthread_barrier_t *b) static int pshared_barrier_wait(pthread_barrier_t *b)

Loading…
Cancel
Save