Product Documentation

Database Administrator's Guide

Previous Topic

Next Topic


LATCH_SPIN <latch_spin_count>

Support for a thread synchronization object on Solaris systems, the latch, can be used as an alternative to a mutex.

A latch is implemented using the atomic processor instructions atomic_swap_8() (which performs an atomic 'test-and-set' operation) and atomic_and_8() (which performs an atomic bitwise AND of the specified two values). set_latch() calls atomic_swap_8() and checks the return value, which is the original value of the latch. If the original value of the latch was zero, this indicates that the thread successfully set the value to one (i.e., acquired the latch). Otherwise, another thread acquired the latch, so the thread retries the operation up to the number of times specified for the latch spin count. If the thread exhausts its spin count without acquiring the latch, the thread sleeps for the number of microseconds specified for the latch sleep time and then retries the operation.

See Also

Note: Latch support is not enabled by default and requires a custom build. Please contact your nearest FairCom office for current availability.