summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-03-28 22:36:55 -0400
committerRich Felker <dalias@aerifal.cx>2011-03-28 22:36:55 -0400
commit4106cdcd2de34bf3b9839e042344d92eae887ecb (patch)
tree9d14a51c59eb318024aa0edf2a1c19ffa0ed6583 /src
parent4cc78719dd22a685ddd89b92ac3bfc308c4c19b3 (diff)
downloadmusl-4106cdcd2de34bf3b9839e042344d92eae887ecb.tar.gz
musl-4106cdcd2de34bf3b9839e042344d92eae887ecb.tar.bz2
musl-4106cdcd2de34bf3b9839e042344d92eae887ecb.tar.xz
musl-4106cdcd2de34bf3b9839e042344d92eae887ecb.zip
revert some more spin optimizations that turned out to be pessimizations
Diffstat (limited to 'src')
-rw-r--r--src/stdio/__lockfile.c2
-rw-r--r--src/thread/pthread_spin_lock.c2
-rw-r--r--src/thread/pthread_spin_trylock.c3
3 files changed, 3 insertions, 4 deletions
diff --git a/src/stdio/__lockfile.c b/src/stdio/__lockfile.c
index 93c94867..c0948255 100644
--- a/src/stdio/__lockfile.c
+++ b/src/stdio/__lockfile.c
@@ -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;
diff --git a/src/thread/pthread_spin_lock.c b/src/thread/pthread_spin_lock.c
index 59fa6ea8..0ab3d64f 100644
--- a/src/thread/pthread_spin_lock.c
+++ b/src/thread/pthread_spin_lock.c
@@ -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;
}
diff --git a/src/thread/pthread_spin_trylock.c b/src/thread/pthread_spin_trylock.c
index 1fc5f73c..c12696b3 100644
--- a/src/thread/pthread_spin_trylock.c
+++ b/src/thread/pthread_spin_trylock.c
@@ -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;
}