소스 검색

optimize contended case for pthread_spin_trylock

Rich Felker 14 년 전
부모
커밋
b8b85a4272
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  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;
 }