Source: Distributed Mutual Exclusion slides. Past-paper questions appear beside the relevant topics.
1. Problem and requirements
-
A critical section (CS) accesses a shared resource. Safety requires at most one process in it at once.
-
Liveness requires progress without deadlock or starvation; fairness concerns the order in which requests are served.
-
Distributed processes coordinate through messages rather than a shared local semaphore.
-
A token-based protocol grants access to the unique token holder; a permission-based protocol gathers replies; a quorum-based protocol asks an intersecting subset of sites.
-
Message complexity counts messages per CS execution. Synchronization delay is the interval from one exit to the next entry. The slides express saturated throughput as , with synchronization delay and average CS duration .
-
A site can be idle, requesting, or executing the critical section. In token algorithms an idle site may still hold the token. A requester waits for its current request to be resolved; further local requests can be queued.
PYQ — Semester paper printed 2023 (file named 2022), CO3
7 marks
- Message complexity: number of messages exchanged for one CS execution; fewer messages reduce communication overhead.
- Synchronization delay: time between one process exiting the CS and the next waiting process entering it.
- Response time: time from sending the request until the requested CS execution finishes; it includes waiting and execution.
- Throughput: number of CS executions completed per unit time. Under continuous demand, the slide model gives , where is synchronization delay and is average CS duration.
- Low-load performance: evaluates the algorithm when few requests compete, so token acquisition or permission delay dominates.
- High-load performance: evaluates the algorithm when requests are continuously waiting; queueing and synchronization delays become significant.
- For example, Lamport’s basic algorithm requires messages per CS and has synchronization delay in the slide model.
2. Lamport’s algorithm
- Each site keeps a request queue ordered by logical timestamp, breaking ties by process ID. Channels are FIFO in the slide model.
- A requester broadcasts
REQUESTand places its request in its own queue. - A receiver adds the request to its queue and returns a timestamped
REPLY. - The requester enters when its request is at the head of its queue and it has received a later timestamped message from every other site.
- On exit it removes its request and broadcasts
RELEASE; receivers remove it from their queues.
- The same timestamp order prevents two sites from both seeing their requests as earliest while satisfying the entry conditions.
- Cost: messages per CS execution; synchronization delay in the slide model. The slide also describes an optimization that can omit some replies, giving between and messages.
PYQ — Semester 2025, CO3: Lamport’s algorithm
- Principle: every site maintains a request queue ordered by Lamport timestamp; process ID breaks ties. The slide model assumes FIFO channels.
- Request: a requester adds its timestamped request to its own queue and broadcasts
REQUESTto all other sites. - Reply: each receiver inserts the request into its queue and sends a timestamped
REPLY. - Entry: the requester enters only when its request is first in its own queue and it has received a later timestamped message from every other site.
- Release: on exit it removes its request and broadcasts
RELEASE; each receiver removes that request from its queue. - Four-site illustration: if requests before in timestamp order, queues place first. enters after the later-message condition holds; enters after releases and its own conditions hold. The detailed sequence follows below.
- Cost: for four sites, each execution uses 3 requests, 3 replies and 3 releases: messages.
- Limitations: all other sites participate; communication cost increases with ; a failed or unresponsive site can block progress; the slide version requires FIFO channels.
- Optimization: if a peer has already sent a later timestamped
REQUEST, it can sometimes omit a separateREPLY: that request serves as the required later message. The slide gives to messages.
Worked example: two competing requests among four sites
Assume and independently issue requests and ; and do not request. All channels are FIFO and all four sites eventually receive both requests.
- Each requester inserts its own request and sends three REQUEST messages. Each receiving site inserts the request in timestamp order and replies. Arrival orders may differ, but once both requests arrive each queue has .
- Once has a later message from each of , its request is at its queue head and it enters. cannot enter while ‘s earlier request is at its queue head.
- exits, removes its own request and sends three RELEASE messages. Each receiver removes ; at the remaining request becomes head.
- After has received the required later message from every peer, it enters, exits and broadcasts its own RELEASE. In the basic algorithm each execution costs nine messages, so these two executions use 18.
PYQ — Semester 2025, CO3
- Fairness claim: pending requests are served in increasing order of the pair .
- Assume has an earlier request than , but enters while ‘s earlier request remains pending.
- Before entry, must have a later timestamped message from every other site, including .
- Because the earlier request was sent before ‘s later message and the channel is FIFO, has received ‘s request before that later message.
- places ‘s request ahead of its own in its ordered queue. Hence ‘s request cannot be at the head while ‘s remains pending.
- This contradicts the entry condition. Thus earlier pending requests are served first; eventual service also assumes reliable delivery, continuing processes and finite CS executions.
- This is logical timestamp order, not necessarily the order of physical arrival times.
PYQ — CT2 2026, Q2: simultaneous requests and a delayed release
- Compare the timestamp first. comes first. At timestamp , compare site IDs, so precedes . Each site orders requests by these same pairs and checks the queue-head and later-message conditions before entering.
- On exit, broadcasts RELEASE. Each recipient keeps in its local queue until it receives that RELEASE, which blocks its own entry in the meantime. If receives it first and its other entry conditions hold, it can enter. still needs the releases from both earlier sites and its own later-message condition.
- Safety: at most one site is in the critical section. A delayed release postpones entry while preserving this property. Liveness: pending requests eventually enter, assuming eventual message delivery, continuing sites and finite critical sections. A release that never arrives can block progress.
Result: .
3. Ricart–Agrawala
- The slide model assumes FIFO channels. Each site tracks deferred replies in an array
RD: setRD[j]when deferring site , and clear it after sending the deferred reply.
- Broadcast a timestamped
REQUESTto all other sites. - A receiver replies immediately if it is idle or the incoming request has priority over its own pending request. Otherwise it defers the reply, including while it is in the CS.
- Enter after receiving a
REPLYfrom every other site. - On exit, send all deferred replies. There is no separate release broadcast.
- Timestamp plus process ID gives an unambiguous priority order. A higher-priority requester withholds permission from a conflicting lower-priority request until it exits.
- Cost: messages; synchronization delay under the slide model.
PYQ — Semester 2021, CO3(b)
- Assume both requests are outstanding before either requester receives the other’s request. broadcasts
REQUEST(47, P1)to ; broadcastsREQUEST(32, P2)to . - is idle, so it sends a
REPLYto both and . - compares 32 with 47: has priority, so sends
REPLYto . - compares 47 with 32: its own request has priority, so it defers the reply to .
- After receiving replies from both peers, enters the CS. must wait for ‘s reply.
- finishes and sends the deferred
REPLYto . - Once has both replies, it enters and finishes the CS. Thus the execution order is followed by .
- Each execution uses messages, so the two requests together use 8 messages.
PYQ — Semester 2024, CO3: clocks
7 marks
- Each site maintains a Lamport logical clock and increments it for local events, including issuing a request.
- A message carries the sender’s logical timestamp; on receipt, the receiver updates its clock to exceed both its current value and the received timestamp.
- A CS request is assigned a timestamp when issued. The pair gives requests a definite priority order.
- A smaller timestamp has higher priority; the process ID resolves equal timestamps.
- In Lamport’s algorithm, every site orders its request queue using this pair. Entry also requires a later timestamped message from every other site.
- In Ricart–Agrawala, a requester replies immediately to a higher-priority competing request and otherwise defers its reply until it exits.
- Example: requests and are competing; has priority. Logical clocks order events and do not require synchronized physical clocks.
4. Quorums and Maekawa
-
A quorum is a request set; any two quorums intersect. A voter grants only one conflicting request at a time, so a shared voter prevents both requesters from collecting all permissions.
-
A coterie is a family of pairwise-intersecting quorums. Minimality excludes one quorum containing another; it improves efficiency rather than being the safety argument.
-
Maekawa requests permission from every member of its quorum, enters after all reply, then releases all votes. Quorum size is approximately , giving about messages and synchronization delay in the slide model.
-
Basic Maekawa can deadlock: several processes hold different partial sets of votes while waiting for each other. The modified algorithm uses
FAILED,INQUIRE, andYIELDmessages so a lower-priority request can return a vote needed by a higher-priority one. -
In the symmetric construction, each quorum has members, contains its own requester, and each site appears in quorums. Self-permission does not require a network message, so exact counts depend on whether it is counted.
-
A voter that has granted a vote sends FAILED to a lower-priority waiting requester; if a higher-priority request arrives, it sends INQUIRE to the current grantee. A grantee that cannot complete because it received FAILED (or has yielded and not regained a grant) can YIELD. The voter queues the returned request and grants the highest-priority waiting request.
-
The slides also present a strong global FIFO assumption as an alternative way to avoid the deadlock: every site receives requests in increasing timestamp order. Ordinary FIFO per channel alone does not guarantee this.
-
The slides give up to messages with deadlock-handling messages. Basic Maekawa’s deadlock is a liveness failure, even though intersecting quorums preserve mutual-exclusion safety.
Every pair of request sets shares at least one voter; that shared voter cannot grant both requests simultaneously.
- In the slide’s concrete deadlock, , and . Voters 0 and 2 grant requester 0; voters 1 and 3 grant requester 1; voters 4 and 5 grant requester 2. Requester 0 waits for voter 1, requester 1 waits for voter 5, and requester 2 waits for voter 2: a cycle of held votes.
PYQ — CT1 2024, Q2(a)
2 marks
- No. A Maekawa voter grants its vote based on requests it has received; it cannot know that an earlier-timestamped request is still in transit.
- It may already grant a later request, allowing that request to proceed first. Thus basic Maekawa does not guarantee global timestamp order.
PYQ — CT1 2024, Q2(b)
3 marks
- Let , and . Suppose 0 holds votes 0 and 2; 1 holds votes 1 and 3; 2 holds votes 4 and 5.
- Requester 0 needs voter 1, requester 1 needs voter 5, and requester 2 needs voter 2. Thus 0 waits for 1, 1 waits for 2 and 2 waits for 0.
- None has all its votes, so none can enter and release its votes: the circular wait is a deadlock.
5. Suzuki–Kasami token algorithm
- One token exists. A site enters its CS only while holding it.
- Each site maintains request sequence numbers
RN; the token maintains last-served numbersLNand a queue of waiting sites. - is the largest sequence number from known at ; on the token is the sequence number of ‘s most recently served request. If , has an outstanding request in the one-request-per-site model.
- A requester without the token increments its own sequence number and broadcasts
REQUEST. Other sites update their record; an idle token holder may forward the token to the requester. - On receiving
REQUEST(j,n), site updates . An idle token holder sends the token to when . - On exit, the holder updates its
LNentry, adds outstanding requesters not already in the token queue, and sends the token to the next queued site if there is one. - If the requester already holds an idle token, no message is needed. Otherwise the slide gives messages to obtain it and synchronization delay or .
PYQ — Semester 2025, CO3
- Safety: exactly one token exists and a site must hold it throughout its CS; therefore two sites cannot execute the CS simultaneously.
- Site records the greatest request number received from as ; the token records the latest completed request as .
- Under the one-outstanding-request-per-site model, identifies an outstanding request and prevents an old request from being treated as new.
- After its CS, the token holder records its completed request, adds outstanding requesters not already in the token queue and forwards the token to the queue head.
- Liveness: reliable eventual delivery makes a pending request known; finite CS executions and continued forwarding allow it to be queued and served.
- At most other sites have an outstanding request ahead under this model. With no failures and continued execution, the requester receives the token in finite time.
PYQ — Semester 2024, CO3
8 marks
- Purpose: distributed mutual exclusion ensures that at most one site executes the critical section for a shared resource at a time.
- Token-based: a single unique token represents the right to enter; a site enters only while holding it.
- In Suzuki–Kasami, a site without the token broadcasts a request. The token contains a queue of waiting sites and is forwarded to a requester.
- Non-token-based / permission-based: a requester exchanges messages to obtain the permission required by the protocol; timestamps order competing requests.
- In Lamport’s algorithm, a site broadcasts a request, maintains a timestamp-ordered queue, waits for the required messages and broadcasts a release after its CS.
- In Ricart–Agrawala, the requester waits for a reply from every other site; a competing site may defer its reply until it finishes.
- Quorum-based: a requester obtains permission from a selected subset of sites rather than all sites. Every pair of quorums intersects.
- In Maekawa’s algorithm, a shared quorum member grants one vote at a time, ensuring safety. Basic Maekawa may deadlock, whereas modified Maekawa handles competing partial votes.
PYQ — Semester 2024, CO3: distributed setup
8 marks
- A distributed system has processes at different sites which cannot rely on a common local semaphore; they coordinate access to a shared resource by messages.
- A process requests entry, waits until its algorithm’s entry condition is satisfied, executes its CS and then releases its permission or token.
- Lamport: each site maintains a timestamp-ordered request queue. A requester broadcasts
REQUESTand peers queue it and send timestamped replies. - It enters when its request is first in its queue and it has a later timestamped message from every peer; after exiting it broadcasts
RELEASE. - Ricart–Agrawala: a requester broadcasts to all peers and enters only after all reply. A process defers a lower-priority competing request until it exits.
- Maekawa: a requester collects votes from an intersecting quorum; a common voter cannot vote for two conflicting requests simultaneously.
- Suzuki–Kasami: only the unique token holder may enter; the token is transferred to waiting requesters.
- These mechanisms ensure at most one site enters at a time. Progress additionally depends on reliable communication, continuing processes and finite CS executions; basic Maekawa may deadlock.
PYQ — Semester paper printed 2023 (file named 2022), CO3: progress
7 marks
- Progress / liveness: if processes request the CS, the protocol should continue to grant access; a pending request should not wait forever.
- Deadlock freedom: the system must not reach a state where requesters wait indefinitely in a cycle and none can proceed.
- Starvation freedom: each pending request must eventually be served, rather than being bypassed indefinitely.
- Ordering: Lamport and Ricart–Agrawala use timestamp priority and process IDs to order competing requests.
- Releasing permission: in Ricart–Agrawala, a process sends deferred replies when it exits, allowing waiting requesters to proceed.
- Token forwarding: Suzuki–Kasami records outstanding requests, queues them and transfers the unique token after the holder finishes.
- Progress assumes eventual message delivery, participating processes that continue to execute, and finite CS durations. Basic Maekawa can deadlock; its modified version uses
FAILED,INQUIREandYIELDto resolve competing votes.
6. Comparison for revision
| Algorithm | Permission or token | Messages per CS in the slide model | Synchronization delay | Main limitation |
|---|---|---|---|---|
| Lamport | All peers, timestamp-ordered queues | ; optimized to | All peers participate; FIFO model | |
| Ricart–Agrawala | All peers, deferred replies | A missing reply can block progress | ||
| Basic Maekawa | All members of an intersecting quorum | About | Can deadlock; self-votes affect exact network counts | |
| Modified Maekawa | Quorum plus deadlock-handling messages | Slides give up to | Depends on contention | Extra messages and coordination |
| Suzuki–Kasami | Unique token and broadcast requests | 0 with idle token; otherwise slide gives | 0 or | Token must remain unique and available |
Here is one message transmission delay in the slides’ performance model. The costs assume no failures and should not be treated as universal bounds under retransmissions, arbitrary delays or changed counting conventions.
PYQ — CT2 2026, Q3: choosing an algorithm for 100 sites
Solution — For the standard comparison, take as one message delay and count one critical-section execution with 100 sites. Actual delays can grow with contention or disrupted delivery.
| Algorithm | Messages per execution in the slide model | Synchronization delay | Coordination |
|---|---|---|---|
| Lamport | in the basic version | All 99 peers participate. Each maintains an ordered queue and processes a separate release. | |
| Ricart–Agrawala | All 99 peers must reply. Deferred replies replace the release broadcast. | ||
| Maekawa | About in the basic version, roughly at the upper end of the slide model with deadlock handling | in the basic model | Contact a quorum of roughly 10 voters. Intersecting quorums require vote tracking, with extra messages to resolve conflicts. |
Choice and heavy load: Modified Maekawa is a reasonable choice if communication failures are transient and the required voters eventually respond. Small quorums reduce per-request traffic compared with contacting all 99 peers. Under heavy contention, overlapping quorums still queue requests at shared voters, and vote yielding and reassignment add communication and wait time. Throughput can be limited by busy voters and by the single shared critical section.
Limitation and improvement: A missing grant or release can stall sites that need that voter. For transient message loss, use acknowledged retries with unique request IDs and duplicate suppression to preserve the one-vote rule. A permanently unavailable voter needs safe quorum reconfiguration that preserves intersection and accounts for outstanding grants. A timeout alone cannot safely grant permission.
Result: Modified Maekawa reduces message traffic for this workload, with a longer basic handoff and additional work to manage contention and recover communication.
7. Additional concepts and past-paper questions
The following background extends the slides and precedes the related questions.
- Centralized mutual exclusion: a coordinator keeps track of the resource and queues requests. A requester sends
REQUEST; the coordinator sendsGRANTwhen free; the requester sendsRELEASEafter its CS. A fair queue and eventual service prevent starvation. The coordinator can become a bottleneck and its failure can halt the basic protocol. - Applications: mutual exclusion protects concurrent updates or exclusive use of shared records, files, devices, reservations and scheduler state.
- Asynchronous shared memory: processes communicate through registers with no fixed bound on relative process speeds. Registers can be categorized by who may read/write them and by safe, regular or atomic consistency semantics; the question below defines both classifications.
- Bounded-delay optimization: if message delivery has a known upper bound, a process can interpret silence after a sufficient timeout as permission, provided the protocol explicitly reports withheld permissions and the timing and reliability assumptions hold.
- Token response time: low load has little contention; high load adds waiting for other token holders. The precise time depends on the token protocol and its queue.
PYQ — Semester paper printed 2023 (file named 2022), MCQ
- Correct option: (d) All of the mentioned.
- A coordinator handles requests, sends a grant/reply, and receives a release after the CS.
- Starvation freedom holds if the coordinator uses a fair queue, messages are delivered and each CS finishes.
PYQ — CT2 re-test 2022, Q2 and Semester paper printed 2023, CO3
7 marks
- Database updates: prevent concurrent transactions from interfering while updating the same record, such as an account balance.
- Distributed file access: serialize conflicting modifications to a shared file to prevent lost or inconsistent writes.
- Banking and payments: allow one operation at a time to update a protected account or transaction record.
- Inventory and reservations: protect stock counts or seat allocations so two users do not reserve the same last item.
- Shared peripheral devices: coordinate exclusive use of a printer, robot or other device that cannot safely handle conflicting commands.
- Distributed job scheduling: protect shared scheduler state so the same exclusive job or resource is not assigned twice.
- Shared counters and configuration: serialize read-modify-write operations on counters or protected configuration to avoid lost updates.
- The critical section must cover the whole operation that requires exclusivity; the coordination mechanism must be reliable under the assumed failures.
PYQ — Semester 2024, CO3: centralized versus distributed
7 marks
- Control: centralized uses one coordinator to grant access; distributed algorithms coordinate among multiple sites without a single permanent coordinator.
- Permission: a centralized requester asks the coordinator; distributed algorithms obtain all-peer permissions, quorum votes, or a unique token.
- Messages: centralized access normally uses
REQUEST,GRANTandRELEASE—3 network messages when requester and coordinator differ. Lamport uses and Ricart–Agrawala per CS. - Decision: the coordinator tracks whether the resource is free and queues requests; distributed decisions use timestamps, intersecting votes or token possession.
- Bottleneck: the coordinator handles all requests and may become a bottleneck; distributed designs spread coordination, though individual voters or token holders can still be bottlenecks.
- Failure: coordinator failure blocks the basic centralized scheme until recovery or replacement. Distributed algorithms also have failure weaknesses: a missing reply, failed voter or lost token can block progress.
- Complexity: centralized management is simpler; distributed approaches need more coordination and failure handling. Both can ensure safety and fairness when their respective assumptions hold.
PYQ — Class Test 1, Q3 and Semester 2021, Q3(a)
8 marks
- Yes. Let be the known maximum one-way message delay. Zero-drift clocks need not agree on their displayed times: each site can measure elapsed intervals of .
- Replace an immediate positive reply by silence. On receiving a request, a site immediately sends a
DENYonly if Ricart–Agrawala would defer permission; it records the deferred request. - A requester broadcasts its timestamped request and waits after sending. If no
DENYarrives from a particular site by the deadline, it treats that site’s silence as permission. - A site that has denied permission sends an explicit
GRANTto that requester when it can release the deferred permission, normally on leaving its CS. A requester receivingDENYwaits for that grant before entering. - Why the timeout works: the request reaches a peer within and its immediate
DENY, if needed, returns within another . Thus a missing denial after means that peer did not withhold permission, assuming reliable delivery and negligible processing time. - For competing requests, the Ricart–Agrawala timestamp/ID rule still determines which permission is deferred. A process in the CS denies a conflicting request, preserving safety. Requests, denials and grants must identify the relevant request; handle a denial and grant received out of order correctly.
- With no contention, only request messages are sent instead of , so the message count improves. With contention,
DENYand laterGRANTmessages add overhead; this is not a universal worst-case improvement. - The method requires the stated strict delay bound, no message loss or crashes during the protocol, reliable elapsed-time measurement and a deadline rule that includes messages arriving exactly at . A timeout alone is unsafe if those assumptions fail.
- Source: Ricart and Agrawala discuss changing the sense of replies under bounded message transmission time: original paper.
PYQ — CT2 2022 and semester paper printed 2023: asynchronous shared memory
15 marks in CT2: 5 + 5 + 5. The semester paper assigns 6 + 8 + 7 marks.
(a) Types of asynchronous shared memory
- In an asynchronous shared-memory model, processes communicate by reading and writing shared registers; their relative execution speeds are not bounded.
- Registers may be classified by access: SRSW has one reader and one writer; MRSW has multiple readers and one writer; MRMW has multiple readers and multiple writers. Access classification is distinct from consistency semantics.
- A safe register returns the last completed value when a read does not overlap a write; a read overlapping a write may return any value in the register’s domain.
- A regular register returns the last completed value when there is no concurrent write; an overlapping read returns the previous value or a concurrently written value.
- An atomic register behaves as if every read and write occurs instantaneously at a point between its invocation and completion, respecting real-time order.
(b) Mutual exclusion algorithm: Lamport
- Each site keeps a queue ordered by logical timestamp and process ID; the slide model assumes FIFO channels.
- A requester inserts its request locally and broadcasts
REQUESTto every other site. Receivers insert it in their queues and send timestampedREPLYmessages. - The requester enters when its request is at the head of its queue and it has received a later timestamped message from every peer.
- On exit it removes its request and broadcasts
RELEASE; recipients remove that request. Each execution uses messages in the basic version. - If two sites entered concurrently, the later request could not be at the head while the earlier pending request was present. Hence mutual exclusion holds.
(c) Progress in an asynchronous distributed system
- Asynchrony means there is no known fixed bound on process or message delays; it does not mean a correct message must be lost.
- Progress is established under assumptions of eventual message delivery, processes continuing to execute, and finite CS executions.
- Lamport’s timestamp order gives pending requests a consistent priority. Each peer eventually sends the required later message, and earlier requests eventually complete and release.
- The earliest pending request eventually reaches the head of its queue and enters; repeated releases allow subsequent requests to proceed. Thus there is no starvation under these assumptions.
- Failure or a permanently lost message can block an all-peer algorithm. Basic Maekawa can deadlock even without failures; additional deadlock handling is necessary.
- Register definitions: Yale shared-memory notes; research discussion of safe, regular and atomic registers.
PYQ — CT1 2024, Q2(c)
2 marks
- Low load: there is little contention. In Suzuki–Kasami, response time is approximately if the requester already holds the idle token, or if it sends a request to an idle holder and receives the token. Here is one message delay and is CS duration.
- High load: the requester may wait for other CS executions and token transfers, so response time increases with queue position. As an illustrative model, if complete executions are ahead and each handoff takes , ; actual time depends on the token location and remaining execution time.
- The bounded-delay Ricart–Agrawala question also appears in the 2021 semester paper; the 2022 and 2023 shared-memory questions have different mark allocations as noted above.













