IT lexicon › Programming › Lock-coupling

Lock-coupling

Programming På svenska → Updated: 2026-11-15

A technique for safely locking multiple nodes sequentially while navigating a tree structure, avoiding deadlock.

When traversing a tree, you often need to hold locks on multiple nodes to maintain invariants. A naive approach — lock root, then branches, then leaves — can deadlock if two threads traverse from opposite ends. Lock-coupling solves this by always locking in the same order: lock the child node, then release the parent, and continue downward. If you need to hold two levels at once, you keep both locks only while you're actively modifying.

This technique is fundamental in database kernels and concurrent B-trees, a classic solution from the 1970s that remains the standard for preventing deadlock during concurrent tree traversal.

← Back to the lexicon