An apparatus and method for distributed intersystem lock optimization are provided.
With the apparatus and method of the present invention, the time required to obtain
an uncontested lock, meaning a lock that no other program or process in the distributed
system is simultaneously attempting to acquire, is minimized. The apparatus and
method of the present invention increases the speed with which locks are acquired
by splitting the process of obtaining a lock into two separate operations: a test
for contention, and then if contention exists, a full lock operation. The test
for contention is made fast by associating each lock with a memory location, and
using an atomic operation or the like, to atomically set the memory location associated
with the lock to a different value. If the lock is found to be contested, meaning
that another program or process has already locked it, control is turned over to
a slower operation than ensures that the lock-requesting program or process will
eventually be granted the lock.