What does Atomic Locks for Many Windows conclude, in numbers, about “Leases, Clocks and Fencing Tokens”?
Answer: Program p41 showed that steps of a single shared clock create no overlap, while mixing a monotonic clock with the wall clock does: a 5-second step gives 3.000 seconds of overlap, and a 3600-second step gives 58.000 seconds. Program p42 showed that with perfect clocks a 60-second lease with a 2-second margin still lets 0.000976 of writes land late, almost all because of sleep. Program p43 showed that the 380 late writes all overwrite new data under blind overwriting and never do when the storage checks tokens. A lease answers the question of what to do when the owner dies, but its answer about whether the owner is dead is a guess based on time. How costly is a wrong guess, and how long must a silence last before the owner can be declared dead? The next chapter does that reckoning.
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. printed values that match the answer: 3.000, 3600, 58.000, 60
| T = 60 s, margin m = 2 s | ||
| scenario | overlap(s) | margin need(s) |
| one wall clock, both read it, +5 s | 0.000 | 0.000 |
| one wall clock, both read it, -5 s | 0.000 | 0.000 |
| holder monotonic, healer wall +1 s | 0.000 | 1.000 |
| holder monotonic, healer wall +5 s | 3.000 | 5.000 |
| holder monotonic, healer wall +3600 s | 58.000 | 60.000 |
| two hosts, skew 0.5 s, 100 ppm | 0.000 | 0.488 |
| two hosts, skew 30 s | 28.000 | 30.000 |
| both monotonic, one host | 0.000 | 0.000 |
Show the full program
# Chapter 4. p41: when a lease lets two windows act at once.
# A lease of T seconds is granted at real time 0. The holder stops at
# T - m on its own clock (m = safety margin); a healer takes over when
# its own clock says the lease has run out. Clocks have a rate error
# (ppm) and may be stepped (NTP correction, zone or sync-folder skew).
# Overlap = real seconds in which both may act. Values illustrative.
T, M = 60.0, 2.0
def overlap(h_rate, h_step, g_rate, g_step, same=False):
# 持有者在自身时钟读到 T - m 时停手;接管者读到 T 时动手
# 同一时钟:两者一起跳,持有者的读数与接管者同步
if same:
h_rate, h_step = g_rate, g_step
t_h = max(0.0, (T - M - h_step) / (1.0 + h_rate))
t_g = max(0.0, (T - g_step) / (1.0 + g_rate))
need = max(0.0, T - (1.0 + h_rate) * t_g - h_step)
return max(0.0, t_h - t_g), need
rows = (
("one wall clock, both read it, +5 s", 0, 0, 0, 5.0, True),
("one wall clock, both read it, -5 s", 0, 0, 0, -5.0, True),
("holder monotonic, healer wall +1 s", 0, 0, 0, 1.0, False),
("holder monotonic, healer wall +5 s", 0, 0, 0, 5.0, False),
("holder monotonic, healer wall +3600 s", 0, 0, 0, 3600.0, False),
("two hosts, skew 0.5 s, 100 ppm", 1e-4, 0, -1e-4, 0.5, False),
("two hosts, skew 30 s", 0, 0, 0, 30.0, False),
("both monotonic, one host", 0, 0, 0, 0.0, False),
)
print("T = %.0f s, margin m = %.0f s" % (T, M))
print("scenario overlap(s) margin need(s)")
for name, hr, hs, gr, gs, same in rows:
ov, need = overlap(hr, hs, gr, gs, same)
print("%-38s %9.3f %14.3f" % (name, ov, need))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 4: Leases, Clocks and Fencing Tokens. 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 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
- Chapter 8 · Closing the Loop: a Formal Health Check of This Series' Lock Protocol and a Pre-Registered Test