Explorar el Código

optimize contended case for pthread_spin_trylock

Rich Felker hace 14 años
padre
commit
b8b85a4272
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      src/thread/pthread_spin_trylock.c

+ 2 - 1
src/thread/pthread_spin_trylock.c

@@ -2,5 +2,6 @@
 
 int pthread_spin_trylock(pthread_spinlock_t *s)
 {
-	return -a_xchg(s, 1) & EBUSY;
+	if (*s || a_xchg(s, 1)) return EBUSY;
+	return 0;
 }