Skip to main content

Mutex requirements; token vs non-token

Short answer

Requirements: safety (at most one in CS), liveness (no deadlock), fairness (no starvation), fault tolerance, low overhead. Non-token (Ricart-Agrawala): permission from all, 2(N-1) messages, timestamp ordering. Token-based: unique token circulates, 0 to N-1 messages, no starvation. Non-token has high overhead, token-based risks token loss.

What are the basic requirements for mutual exclusion in distributed system? Explain the non-token based distributed mutual exclusion algorithm and compare it with token based algorithm.

Basic requirements for mutual exclusion

  1. Safety (mutual exclusion): at most one process is in the critical section (CS) at a time.
  2. Liveness (no deadlock): if requests are made, some process eventually enters; no process waits forever for messages.
  3. Fairness / no starvation: every requesting process eventually enters, normally in the order in which requests were made (happened-before order).
  4. Fault tolerance: the algorithm survives a failure of a process or loss of a message (desirable).
  5. Low message overhead and small delay (performance).

Non-token-based algorithm: Ricart-Agrawala

Processes exchange timestamped messages to get permission; no token exists.

  1. To enter, process Pi sends REQUEST(Ci, i) (Lamport timestamp) to all other N−1 processes.
  2. A process Pj that gets a request replies immediately if it is neither in the CS nor wanting it, or if its own request has a larger timestamp. If it is in the CS, or wants it with an earlier timestamp, it defers the reply.
  3. Pi enters the CS when it has received REPLY from all N−1 processes.
  4. On leaving, Pi sends the deferred replies. Messages: 2(N−1) per entry; synchronisation delay: 1 message time.

Comparison with token-based algorithms (e.g. token ring, Suzuki-Kasami)

PointNon-token basedToken based
PermissionObtained from other processesPossession of the unique token
OrderingTimestampsToken position/queue
Messages per entry2(N−1) (high)0 to N−1 (ring) or N (broadcast)
SafetyBy agreement of allBy uniqueness of token
FailureA crashed process blocks; detectable by missing replyToken can be lost; needs detection and regeneration
Idle trafficNoneToken keeps circulating in ring
DelayAlways a round of messagesZero if holder wants CS again
StarvationNoneNone in ring
ExamplesLamport, Ricart-Agrawala, MaekawaToken ring, Suzuki-Kasami, Raymond

✓ Answer checked by Claude Opus 5.5 (high effort)

All Distributed System chapter 6 questions →