This webpage gives some details of the global snapshot algorithm.
taken_local_snapshot = False
channel_snapshots = {key: [] for key in predecessors}
channels_recorded = {key: False for key in predecessors}
start()
def receive(message, sender):
if isinstance(message, Marker) and not taken_local_snapshot:
local_snapshot = record_state()
taken_local_snapshot = True
channels_recorded[sender] = True
output_message = Marker()
for receiver in successors:
send(output_message, receiver)
elif isinstance(message, Marker) and taken_local_snapshot:
channels_recorded[sender] = True
else:
if taken_local_snapshot and not channels_recorded[sender]:
channel_snapshots[sender] = \\
channel_snapshots[sender].append(message)
The remainder of this webpage consists of examples.
Figure 2 is a representation of a computation with event sequence
\([0, 1, 2, \ldots, ]\) and agents \(X, Y, Z\) without a concurrent OS
algorithm, and figure 3 shows how the OS changes this computation.
Events later in the computation are placed to the
right of earlier events.
Figure 3 shows how a client's computation is changed when the OS takes
snapshots.
The local snapshots taken by agents are shown as a yellow
circle on the agents' timelines.
The OS delays event 3 so that it occurs after events 4, 5, 6, and 7,
as shown in the figure.
The OS changes the computation, but it does not change the dataflow.
When agents X and Z each receive the markers, they take their local
snapshots because they haven't taken snapshots earlier.
When X and Z take their snapshots they send markers out on their
output channels.
The markers sent by X are shown in figure 7.
The markers sent by Z are not shown in the figure.
Figure 8 shows how agent Y determines the state of the channel from X
to Y in the global snapshot.
Y starts recording the messages it receives along this channel after Y
takes its snapshot and stops the recording when it receives a marker
on this channel
The only message in this interval is the message corresponding to edge
(6, 7).
K. Mani Chandy, Emeritus Simon Ramo Professor, California Institute of Technology