[Openmcl-devel] Quick HW question...

Derrell Piper ddp at electric-loft.org
Tue Nov 16 10:39:53 PST 2010


> (block got-lock
>    (loop
>      (dotimes (i *spin-lock-tries*)
>        (if (%store-conditional something somewhere)
>          (return-from got-lock t)))
>      (give-up-timeslice)))

Not sure if this was pseudo-code or not, but...

A trick I've seen used is to do a non-interlocked test of the spinlock
before even trying the %store-conditional.  The non-interlocked test
will (mostly) avert the expensive %store-conditional when there's
spinlock contention.  Depending upon your locking characteristics, this
can be a huge win.  We used this in the VMS operating system where we
had a hierarchy of locks that had to be acquired in a particular order,
though it's applicable in the general case too.  

Might be worth profiling...

Derrell




More information about the Openmcl-devel mailing list