Преглед изворни кода

optimize spin lock not to dirty cache line while spinning

Rich Felker пре 10 година
родитељ
комит
7b1fb0c526
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      src/thread/pthread_spin_lock.c

+ 1 - 1
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;
 }