| Server Side Delphi - Kestral Computing | Start | Index | Next |
Spin Locks |
|||
A Spin lock Sits in a tight loop trying to enter the critical section for a short time
const SpinCount = 4000; procedure SpinLock(ct:TRTLCriticalSection); var i:integer; begin i := 0; while (i < SpinCount) and not TryEnterCriticalSection(ct) do inc(i); if i = SpinCount then EnterCriticalSection(ct); end; |
In Windows NT (SP3+)
const SpinCount = 4000; ... SetCriticalSectionSpinCount(ct, SpinCount); |
(very unstable in SP3)
| Grahame Grieve |