What does Atomic Locks for Many Windows conclude, in numbers, about “Closing the Loop: a Formal Health Check of This Series' Lock Protocol and a Pre-Registered Test”?
Answer: Chapter 8 gives a formal health check of the lock protocol this series uses: none of its schedules gives a double claim as written, while an automatic cleaner gives double claims in 45 of 48 final states. It presents the distilled "Lock-Protocol Race Enumerator" and a pre-registered test; showing a double-claim rate below one in a thousand with no failures takes 2995 batches. Marked boxes separate published evidence, runnable Python calculations (19 programs), classical sources and the author's hypotheses.
Scope of the numbers: Marked boxes separate published evidence, runnable Python calculations (19 programs), classical sources and the author's hypotheses.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 45, 48
| variant | states | ends | double | no-status | unclaimed |
|---|---|---|---|---|---|
| as written | 111 | 3 | 0 | 0 | 0 |
| power cuts | 535 | 111 | 0 | 83 | 87 |
| check-then-create | 368 | 7 | 4 | 0 | 4 |
| auto cleaner | 2133 | 48 | 45 | 0 | 0 |
Show the full program
# Chapter 8. p81: a formal health check of this century's claim protocol
# (exclusive-create B-xxx.lock, then write B-xxx.status = drafting;
# forward windows ascend, reverse windows descend, held numbers are
# skipped; orphans go to a human). Four volumes; forward windows F1
# (quota 2) and F2 (quota 1), reverse window R (quota 1). Every
# reachable state is explored in memory. Variants: as written; with
# power cuts (any window may die at any step); with check-then-create;
# with an automatic cleaner that re-claims any lock lacking a status.
from collections import deque
V = 4
WINS = (("F1", 2, False), ("F2", 1, False), ("R", 1, True))
def order(rev):
return list(range(V - 1, -1, -1)) if rev else list(range(V))
def explore(mode):
n = len(WINS) + (1 if mode == "cleaner" else 0)
# 窗口状态:(位置, 已领数, 阶段, 存活);阶段 0 待建锁,1 待写状态,
# 2 已检查待创建(先检查后创建变体)
start = (tuple([None] * V), tuple([False] * V),
tuple([frozenset()] * V), tuple([(0, 0, 0, True)] * n))
seen, todo, ends = {start}, deque([start]), []
while todo:
s = todo.popleft()
lock, stat, bel, ws = s
nxt = []
for w in range(n):
pos, got, ph, alive = ws[w]
if w == len(WINS): # 自动清理者:扫一遍
if pos >= V or not alive:
continue
L, S, B = list(lock), list(stat), list(bel)
if L[pos] is not None and not S[pos]:
L[pos], S[pos] = w, True
B[pos] = B[pos] | {w}
nxt.append((tuple(L), tuple(S), tuple(B),
put(ws, w, (pos + 1, got, 0, True))))
continue
name, quota, rev = WINS[w]
if not alive or got >= quota or pos >= V:
continue
if mode == "power":
nxt.append((lock, stat, bel,
put(ws, w, (pos, got, ph, False))))
vol = order(rev)[pos]
L, S, B = list(lock), list(stat), list(bel)
if ph == 1:
S[vol] = True
st = (pos + 1, got + 1, 0, True)
elif mode == "check" and ph == 0:
st = (pos, got, 2, True) if L[vol] is None else \
(pos + 1, got, 0, True)
elif L[vol] is None or ph == 2:
L[vol] = w
B[vol] = B[vol] | {w}
st = (pos, got, 1, True)
else:
st = (pos + 1, got, 0, True)
nxt.append((tuple(L), tuple(S), tuple(B), put(ws, w, st)))
if not nxt:
ends.append(s)
for t in nxt:
if t not in seen:
seen.add(t)
todo.append(t)
return seen, ends
def put(t, k, v):
t = list(t)
t[k] = v
return tuple(t)
print("variant states ends double no-status unclaimed")
for mode, name in (("plain", "as written"), ("power", "power cuts"),
("check", "check-then-create"),
("cleaner", "auto cleaner")):
seen, ends = explore(mode)
dbl = len([e for e in ends if max(len(b) for b in e[2]) >= 2])
nos = len([e for e in ends
if any(l is not None and not s
for l, s in zip(e[0], e[1]))])
unc = len([e for e in ends if None in e[0]])
print("%-16s %6d %5d %7d %10d %10d"
% (name, len(seen), len(ends), dbl, nos, unc))Single source and citation
Fan, Y. (2026). Atomic File-Lock Protocols for Multiple Windows: Self-Recovering Orphan Locks after Power Loss and Cross-Window Hand-Over State Machines (Version 1.0.0), Chapter 8: Closing the Loop: a Formal Health Check of This Series' Lock Protocol and a Pre-Registered Test. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-254 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026254,
author = {Fan, Yafu},
title = {Atomic File-Lock Protocols for Multiple Windows: Self-Recovering Orphan Locks after Power Loss and Cross-Window Hand-Over State Machines},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · The Race Window: Exhaustive Interleavings of Check-then-Create and Their Width on the Wall Clock
- Chapter 2 · Mutual Exclusion from Reads and Writes Alone: Model-Checking Six Entry Protocols and the Roster Bound
- Chapter 3 · After the Power Cut: Empty Locks, Missing Status and Write-Temporary-then-Link
- Chapter 4 · Leases, Clocks and Fencing Tokens
- Chapter 5 · Judging Orphan Locks: How Long a Silence Means Death
- Chapter 6 · State Machines for Hand-Over between Windows: Transfer, Tokens and a Status That Only Moves Forward
- Chapter 7 · Classical Sources East and West: the Gatekeeper Who "Keeps and Issues the Keys" and Dijkstra in 1965