A one-bit swap object using test-and-sets and a max register
We describe a linearizable, wait-free implementation of a one-bit swap object from a single max register and an unbounded array of test-and-set bits. Each swap operation takes at most three steps. Using standard randomized constructions, the max register and test-and-set bits can be replaced by read-write registers, at the price of raising the cost of a swap operation to an expected O(max(log n, min(log t, n))) steps, where t is the number of times the swap object has previously changed its value and n is the number of processes.
💡 Research Summary
The paper presents a wait‑free, linearizable implementation of a one‑bit swap object that uses only a single max register and an unbounded array of test‑and‑set (TAS) bits. A swap operation returns the previous value of the object while atomically writing a new value (0 or 1). By restricting the object to a single bit, the authors are able to dramatically reduce the cost compared with general‑purpose swap implementations, which can require Θ(n log n) steps per operation (Afek‑Weisberger‑Weisman, 1993).
Algorithmic idea.
The implementation maintains a max register maxRound that stores a “round number” r. The invariant is that r mod 2 always equals the input value v supplied to the swap call. When a process invokes swap(v), it first reads maxRound. If the read value r does not satisfy r mod 2 = v, the process increments r by one and writes the new value back to maxRound. This step guarantees that all processes that entered the same round share the same input value.
After the round is fixed, the process performs a single TAS on the bit `t
Comments & Academic Discussion
Loading comments...
Leave a Comment