Question 4 of 11 · Set 2 · 6 marks
Open in ChatGPTCompare centralized, distributed, and token-based mutual exclusion algorithms and explain their differences in message overhead and fault tolerance.
Introduction
A distributed system shares resources among processes on different machines. Mutual exclusion guarantees that at most one process is inside a critical section at a time, while still letting every process enter eventually. The algorithms differ in the messages they need and in how they behave when a process or a link fails.
Centralized
- A coordinator grants permission: a process sends REQUEST, the coordinator queues it and replies GRANT when the resource is free, and RELEASE returns it.
- Messages: 3 per entry and exit (request, grant, release). Bottleneck: the coordinator.
- Fault tolerance: the coordinator is a single point of failure; a crash blocks everyone until it recovers.
Distributed (Ricart–Agrawala)
- A process broadcasts
(timestamp, id)and waits for a reply from every process. A process replies only when it is not interested, or when its own request has a larger timestamp. - Messages: 2(n − 1) per entry. Fault tolerance: any failed process blocks the requester; n points of failure instead of one.
- Lamport's version uses a total order on timestamps and a REPLY from all; token-ring mutual exclusion passes a token round the ring.
Token-based
- A single token circulates; holding it grants entry to the critical section, and the token carries a queue of waiting requests.
- Messages: 1 per entry in the ring, 0 while idle. Fault tolerance: if the token is lost, the system deadlocks and must detect and regenerate it.
Comparison
| Algorithm | Messages per entry | Failure behaviour |
|---|---|---|
| Centralized | 3 | Coordinator crash blocks all |
| Distributed | 2(n − 1) | Any crash blocks the requester |
| Token ring | 1 (passed) | Lost token deadlocks ring |
Conclusion
Centralized is cheapest in messages but has one point of failure; distributed is symmetric and fault-tolerant only in the sense that no single node decides, but needs 2(n − 1) messages; token-based is cheapest once running but fragile to a lost token. Practical systems: ZooKeeper, etcd: use a replicated coordinator, which is centralised logic with a replicated decision.