Thin Lock Implementation

Bartosz Milewski bartosz at relisoft.com
Wed Aug 20 15:14:05 PDT 2008


Brad Roberts wrote:
> I'll agree that inbetween is relatively rare, but just because there's 
> contention, doesn't require the switch to heavy locks.  In a lot of the 
> code I have written, one spin (assuming the spin utilizes rep; nop;) is 
> sufficient for the 'blocked' acquire to finish it's acquire.  The use of 
> heavy weight locks in that scenario is a net loss.

A thin lock is not a spin lock. It's an optimization on top of the OS 
lock specifically for the no-contention case. If there is contention, 
the OS lock, which is part of FatLock, is used. It presumably does its 
own optimizations, so calling it "heavy weight" may be unfair.



More information about the Digitalmars-d mailing list