diff options
author | Rich Felker <dalias@aerifal.cx> | 2015-04-22 03:16:50 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2015-04-22 03:16:50 -0400 |
commit | 7b1fb0c526936873a260e860ce3bca82113c3d4c (patch) | |
tree | 62adafeeb4ebde15e03c2efa6a675641bcf8209e | |
parent | b8dda24fe1caa901a99580f7a52defb95aedb67c (diff) | |
download | musl-7b1fb0c526936873a260e860ce3bca82113c3d4c.tar.gz musl-7b1fb0c526936873a260e860ce3bca82113c3d4c.tar.bz2 musl-7b1fb0c526936873a260e860ce3bca82113c3d4c.tar.xz musl-7b1fb0c526936873a260e860ce3bca82113c3d4c.zip |
optimize spin lock not to dirty cache line while spinning
-rw-r--r-- | src/thread/pthread_spin_lock.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/thread/pthread_spin_lock.c b/src/thread/pthread_spin_lock.c index df575f08..0462e0f3 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_swap(s, 1)) a_spin(); + while (*(volatile int *)s || a_cas(s, 0, 1)) a_spin(); return 0; } |