Bugzilla bug 132089: use the adaptive pthread mutex type in glibc 2.2 or
authorwtc%netscape.com
Tue, 19 Mar 2002 23:07:49 +0000
changeset 2303 0bb4a3e0699a614a6495673b15db94851cc5f344
parent 2302 c9d87b9a7099f659684141ce7b477e6bc6496026
child 2304 65201a03ebf6c8c0453d00644938fc0599380bb2
push idunknown
push userunknown
push dateunknown
bugs132089
Bugzilla bug 132089: use the adaptive pthread mutex type in glibc 2.2 or higher for better performance.
pr/src/pthreads/ptsynch.c
--- a/pr/src/pthreads/ptsynch.c
+++ b/pr/src/pthreads/ptsynch.c
@@ -66,16 +66,23 @@ static pthread_t pt_zero_tid;  /* a null
 /**************************************************************/
 
 void _PR_InitLocks(void)
 {
     int rv;
     rv = _PT_PTHREAD_MUTEXATTR_INIT(&_pt_mattr); 
     PR_ASSERT(0 == rv);
 
+#ifdef LINUX
+#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
+    rv = pthread_mutexattr_setkind_np(&_pt_mattr, PTHREAD_MUTEX_ADAPTIVE_NP);
+    PR_ASSERT(0 == rv);
+#endif
+#endif
+
     rv = _PT_PTHREAD_CONDATTR_INIT(&_pt_cvar_attr);
     PR_ASSERT(0 == rv);
 }
 
 static void pt_PostNotifies(PRLock *lock, PRBool unlock)
 {
     PRIntn index, rv;
     _PT_Notified post;