]> granicus.if.org Git - musl/commitdiff
optimize spin lock not to dirty cache line while spinning
authorRich Felker <dalias@aerifal.cx>
Wed, 22 Apr 2015 07:16:50 +0000 (03:16 -0400)
committerRich Felker <dalias@aerifal.cx>
Wed, 22 Apr 2015 07:16:50 +0000 (03:16 -0400)
src/thread/pthread_spin_lock.c

index df575f0858681b76afb8895478778b67e8ca2a7b..0462e0f3a4004ca469cf6f99f7c24566f383a423 100644 (file)
@@ -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;
 }