lecture9-GlobalState
lecture9-GlobalState
Monitor
p0 p0
p1 p2 p1 p2
Deadlock No deadlock
Counter example: deadlock detection
• Suppose a monitor uses the simple approach
Monitor
p0
Who is waiting
for you?
p1 p2
Counter example: deadlock detection
• Suppose a monitor uses the simple approach
Monitor
p0
p1 p2
Who is waiting
for you?
p1 p2
p0 is waiting for p1
p1 p2
p1 responds.
Counter example: deadlock detection
• Suppose a monitor uses the simple approach
Monitor
p0
p1 p2
p1 p2
Who is waiting
for you?
p1 p2
p1 p2
p2 responds.
Counter example: deadlock detection
• Suppose a monitor uses the simple approach
Monitor
p0
p1 p2
p1 p2
p1 p2
p0 responds.
Counter example: deadlock detection
• Suppose a monitor uses the simple approach
Monitor
p0
Deadlock!
p1 p2
No deadlock.
Problem
• Simply combining state of each node does not work
– Need to somehow get each one’s state at the right timing
p0 p0
Request
p1
p2
p1 p2
Space-Time diagram
• A graphic representation of a distributed
execution
p0 p0
Grant
p1
p2
p1 p2
Space-Time diagram
• A graphic representation of a distributed
execution
p0 p0
p1
Request
p2
p1 p2
Space-Time diagram
• A graphic representation of a distributed
execution
p0 p0
Request
p1
p2
p1 p2
Space-Time diagram
• A graphic representation of a distributed
execution
States received by the monitor
p0 p0
p1
p2
Monitor
p1
p2
Chandy Lamport protocol
• Global state is consisted of state of each
node and state of each channel
– State of a node: registers, memory, disk, etc
– State of a channel: messages
• Assume we record messages at the receiver side
p0
p1
p2
Chandy Lamport protocol
• If p1 takes snapshot at red arrow, p0’s
snapshot should not include the last two
received messages.
• How to let p0 know? p1 will relay the “take
snapshot” message to p0 as a barrier
p0
p1
p2
Chandy Lamport protocol
• Start: a node sends “take snapshot” to itself
• When a node receives “take snapshot” for the
first time:
– It records application state
– It starts recording all incoming messages
– It relays “take snapshot” to all other nodes
• When to stop recording
– When pj receives “take snapshot” from pi, pj stops
recording incoming messages from pi.
– Recording completes when pj receives “take
snapshot” from every node
Chandy Lamport protocol
p0
p1
p2
Chandy Lamport protocol
p0
p1
p2
Chandy Lamport protocol
p0
p1
p2
Chandy Lamport protocol
p0
p1
p2
Chandy Lamport protocol
p0
p1
p2
p0
p1
p2
p0
p1
p2
p0
p1
Proof
p0
p1
p0
p1
p0
p1
p1
p2