提交 4106cdcd 编写于 作者: R Rich Felker

revert some more spin optimizations that turned out to be pessimizations

上级 4cc78719
......@@ -13,7 +13,7 @@ void __lockfile(FILE *f)
f->lockcount++;
return;
}
while (f->lock || a_cas(&f->lock, 0, tid))
while (a_cas(&f->lock, 0, tid))
if (spins) spins--, a_spin();
else syscall(SYS_sched_yield);
f->lockcount = 1;
......
......@@ -2,6 +2,6 @@
int pthread_spin_lock(pthread_spinlock_t *s)
{
while (a_xchg(s, 1));
while (a_xchg(s, 1)) a_spin();
return 0;
}
......@@ -2,6 +2,5 @@
int pthread_spin_trylock(pthread_spinlock_t *s)
{
if (*s || a_xchg(s, 1)) return EBUSY;
return 0;
return -a_xchg(s, 1) & EBUSY;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册