From: Rich Felker Date: Wed, 22 Apr 2015 07:16:50 +0000 (-0400) Subject: optimize spin lock not to dirty cache line while spinning X-Git-Tag: v1.1.9~28 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7b1fb0c526936873a260e860ce3bca82113c3d4c;p=oweals%2Fmusl.git optimize spin lock not to dirty cache line while spinning --- 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; }