Windows: use spin counts for osi base locks
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 5 Jul 2012 20:52:51 +0000 (16:52 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 6 Jul 2012 04:49:40 +0000 (21:49 -0700)
On multiprocessor systems, spin counts are faster than entering
a processor wait state when there is critical section contention.
Microsoft recommends a count of 4000.  This feature is only available
on XP and above which is fine since OpenAFS master and 1.7 no longer
support Windows 2000.

Change-Id: I1b40d00b2a91e60e1676a53e1c38eb5f9bfadc69
Reviewed-on: http://gerrit.openafs.org/7719
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/client_osi/osibasel.c

index eb00b15..156993c 100644 (file)
@@ -35,7 +35,7 @@ void osi_BaseInit(void)
     int i;
 
     for(i=0; i<OSI_MUTEXHASHSIZE; i++)
-        InitializeCriticalSection(&osi_baseAtomicCS[i]);
+        InitializeCriticalSectionAndSpinCount(&osi_baseAtomicCS[i], 4000);
 
     if ((tls_LockRefH = TlsAlloc()) == TLS_OUT_OF_INDEXES)
         osi_panic("TlsAlloc(tls_LockRefH) failure", __FILE__, __LINE__);
@@ -43,7 +43,7 @@ void osi_BaseInit(void)
     if ((tls_LockRefT = TlsAlloc()) == TLS_OUT_OF_INDEXES)
         osi_panic("TlsAlloc(tls_LockRefT) failure", __FILE__, __LINE__);
 
-    InitializeCriticalSection(&lock_ref_CS);
+    InitializeCriticalSectionAndSpinCount(&lock_ref_CS, 4000);
 }
 
 void