Unbounded single-writer atomic snapshot transition system #
Defines process states (ActiveScan, ProcSnapshotState), global configurations
(SnapshotState), atomic transition labels (SnapshotEvent), single-register transition function
(stepSnapshot), and labelled transition system (snapshotLTS, SnapshotReachable) following
[AAD+93], §3, Figure 3.
Main definitions #
Cslib.Distributed.SetAgreement.ScanMode,Cslib.Distributed.SetAgreement.CollectPhase,Cslib.Distributed.SetAgreement.ActiveScan,Cslib.Distributed.SetAgreement.ProcSnapshotState,Cslib.Distributed.SetAgreement.SnapshotState,Cslib.Distributed.SetAgreement.SnapshotEvent: process states, global configurations, and atomic single-register LTS events.Cslib.Distributed.SetAgreement.completeHistoryAt,Cslib.Distributed.SetAgreement.finishScan,Cslib.Distributed.SetAgreement.stepSnapshot: atomic step transition semantics.Cslib.Distributed.SetAgreement.snapshotLTS,Cslib.Distributed.SetAgreement.SnapshotReachable: labelled transition system and reachability.
Unbounded single-writer algorithm state machine (Figure 3) #
Whether an active scan_i is serving an external ScanRequest_i or the embedded scan inside
UpdateRequest_i(val).
Which of the two sequential collects in Figure 3 lines 2–3 is currently executing.
- collectA : CollectPhase
First collect (
a[1..n] := collect, line 2). - collectB : CollectPhase
Second collect (
b[1..n] := collect, line 3).
Local variables of an active scan_i loop ([AAD+93], Figure 3,
p. 8).
- mode : ScanMode Data
Whether this scan is top-level or embedded inside an
update. - opId : ℕ
Index of the enclosing client operation in
SnapshotState.history. - moved : Finset P
Processes observed to move once in an earlier double collect (
moved[j] = 1). - phase : CollectPhase
- rem : List P
Remaining registers still to read one-by-one in the current collect pass.
- collectAVal : P → SnapshotReg P Data
Accumulated register records read during
collectA. - collectBVal : P → SnapshotReg P Data
Accumulated register records read during
collectB.
Local control state of a single process i : P in Figure 3.
- idle {P : Type u_1} {Data : Type u_2} : ProcSnapshotState P Data
No pending operation (
H_i = ⊥). - scanning {P : Type u_1} {Data : Type u_2} (st : ActiveScan P Data) : ProcSnapshotState P Data
Executing the double-collect
scan_iloop (top-level or embedded). - readyToWrite {P : Type u_1} {Data : Type u_2} (opId : ℕ) (val : Data) (snap : P → Data) : ProcSnapshotState P Data
Embedded
scan_icompleted withsnap; ready to execute atomic writer_i := (val, r_i.seq + 1, snap)(line 2 ofupdate_iin Figure 3).
Computable test for whether a process control state is .idle.
Global configuration of the unbounded single-writer snapshot implementation.
- reg : P → SnapshotReg P Data
Array of
nsingle-writer,n-reader atomic registersr_1, …, r_n. - proc : P → ProcSnapshotState P Data
Per-process local control states.
- history : List (SnapshotOpRecord P Data)
Recorded client invocation/completion history for linearizability verification.
- stepCount : ℕ
Global transition counter (
historytimestamps).
Initial configuration: all registers hold (dInit, 0, fun _ => dInit), all processes are
idle, and history is empty.
Atomic transition labels of the snapshot implementation: client invocations or one atomic step
of process i (reading at most one register reg j or writing reg i).
- invokeScan {P : Type u_1} {Data : Type u_2} (i : P) : SnapshotEvent P Data
Idle process
iinvokesScanRequest_i. - invokeUpdate {P : Type u_1} {Data : Type u_2} (i : P) (val : Data) : SnapshotEvent P Data
Idle process
iinvokesUpdateRequest_i(val). - step {P : Type u_1} {Data : Type u_2} (i : P) : SnapshotEvent P Data
Active process
iexecutes one atomic step (a single register read, local loop check, or single-writer register write).
Mark history record opId with a new status if in bounds.
Finish a completed scan_i (either returning snap to an external caller or advancing an
embedded update_i to readyToWrite).
Deterministic partial step function executing one atomic SnapshotEvent (none when the
precondition is not enabled). Every .step i accesses at most one shared register; relative to
[AAD+93] Figure 1 (p. 4), external scan completion (finishScan) is
fused with .doneScan and update_i's atomic register write (readyToWrite) is fused with
.doneUpdate.
Cslib.LTS of the unbounded single-writer atomic snapshot implementation.
Reachability from SnapshotState.init dInit in snapshotLTS.