[Openmcl-devel] Quick HW question...
ddp at electric-loft.org
Tue Nov 16 12:39:53 CST 2010
> (block got-lock
> (dotimes (i *spin-lock-tries*)
> (if (%store-conditional something somewhere)
> (return-from got-lock t)))
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...
More information about the Openmcl-devel