05a Mutex Slides
05a Mutex Slides
Week 5: Part 1
Distributed Mutual Exclusion
Mutual exclusion
Examples • Update a fields in database tables
• Modify a shared file
• Modify file contents that are replicated on multiple servers
Also desired:
Fairness:Each process gets a fair chance to hold the resource: bounded wait time &
in-order processing of requests
• Process identification
– Every process has a unique ID (e.g., address.process_id)
• Reliable communication
– Network messages are reliable (may require retransmission of lost/corrupted messages)
• Live processes
– The processes in the system do not die
• Token-based
– A process can access a resource if it is holding a token permitting it to do so
• Contention-based
– A process can access a resource via distributed agreement
request(R) P1
request(R)
P2
R in use by: P0
R Request Queue
C
P1
P2 P0
P1
P2
R in use by: P10
R Request Queue
C
P12
P2 P0
grant(R)
release(R)
P1
P2
R in use by: P12 grant(R)
R Request Queue
C
P2
P0 release(R)
P1
P0
P5 P1
P4 P2
P3
P3
token(R)
P0
P5 P1
P4 P2
P3
P0
Your turn to access
P5 P1
resource R
P4 P2
P3
P0
P5 P1
P3
P0
P5 P1
P4 P2
P0
P5 P1
P3
P0
P4 P2
P3
P0
P5 P1
P4 P2
P3
P0
Your turn to access
P5 P1
resource R
P4 P2
P3
• Delay:
– Request = 0…N-1 messages
– Release = 1 message
If your request is at the head of the queue Sample request queue for R
Identical at each process
AND you received Replies for that request
… then you can access the critical section
• Problems
– N points of failure
– A lot of messaging traffic
• Requests & releases are sent to the entire group
• Problems
– N points of failure
– A lot of messaging traffic: requests & releases are sent to the entire group
• Maekawa
– Partitions the group – each subgroup has at least one process in common with
another subgroup
– Performance improved to 3 𝑁 … 6 𝑁 messages
• Many more…