提交 de543b05 编写于 作者: R Rich Felker

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).
上级 ede5ae7b
......@@ -13,9 +13,9 @@ void __vm_lock(int inc)
void __vm_unlock(void)
{
if (vmlock[0]>0) a_dec(vmlock);
else a_inc(vmlock);
if (vmlock[1]) __wake(vmlock, 1, 1);
int inc = vmlock[0]>0 ? -1 : 1;
if (a_fetch_add(vmlock, inc)==-inc && vmlock[1])
__wake(vmlock, -1, 1);
}
static int pshared_barrier_wait(pthread_barrier_t *b)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册