Saral Shiksha Yojna
Courses/Distributed Systems

Distributed Systems

CS3.401
Prof. Kishore KothapalliMonsoon 2025-264 credits

Lamport, Ricart-Agrawala, Maekawa, Suzuki-Kasami, Raymond — Complete Comparison

NotesStoryCaveman
Unit 5 — Distributed Mutual Exclusion

One cave, one fire. Only ONE Ugg cook at a time.

Distributed mutual exclusion (DME) — many caves, many Ugg, all want the one magic fire-pit (the critical section, CS). Only ONE Ugg in fire-pit at once. In a single cave, easy: grab bone-lock, cook, drop bone-lock. But these caves far apart. No shared bone-lock, no big chief to boss everyone. Only shout-messages between caves. So how make sure only one Ugg cook? Ugg teach you. Five ways. Two tribes.

What a good fire-rule must promise

Every fire-rule keep three promises:

  • Safety — never two Ugg in fire-pit same moment. Most important.
  • Liveness — every Ugg who ask, EVENTUALLY cook. No Ugg wait forever.
  • Fairness — Ugg cook in the order they ask, by timestamp (shiny-stone clock number). First ask, first cook.

Ugg measure a fire-rule four ways:

  • Message complexity — how many shout per one cook.
  • Synchronisation delay (SD) — how long fire-pit sit empty between one Ugg leave and next Ugg enter.
  • Response time — from ask until done cook.
  • Throughput , where = how long one Ugg cook. Small SD → more dinner per moon.

Tribe One: ask-permission (non-token)

Lamport — old grandfather rule. Need FIFO shout-paths (shouts arrive in the ORDER sent). Every Ugg keep a request queue — line of stones sorted by timestamp.

  • Want cook: shout to all; drop own stone in own queue.
  • Other Ugg hear it: queue the stone, shout back a timestamped REPLY.
  • Enter fire-pit only when BOTH true: L1 — got a shout with bigger timestamp from EVERY other cave (any shout counts, not only a REPLY); L2 — own stone sit at the TOP of own queue.
  • Done: throw own stone away, shout RELEASE. All Ugg remove that stone.

Cost: shouts per cook (REQUEST + REPLY + RELEASE to each other cave). SD (one shout-time).

Ricart-Agrawala — smart grandchild. Kill the RELEASE shout. No FIFO needed!

  • Shout REQUEST.
  • Hear a REQUEST: shout REPLY if you idle OR your own timestamp is bigger. Else defer — hold the REPLY in fist, send later.
  • Enter after REPLY from all caves.
  • Done: now send every held-back REPLY.

Cost: shouts. SD . Beats grandfather. Roucairol-Carvalho trick: once you got REPLY from cave-j, no need ask cave-j again to re-cook — unless you sent cave-j a REPLY in between. Shouts sink to up to .

Maekawa — do NOT ask everyone. Ask only a small hunting-party, the quorum . Party rules: you sit in your own party (); every two parties SHARE at least one Ugg ( — shared Ugg is the judge); all parties same size ; each Ugg sit in parties. Best size , because the sharing rule forces .

V1: shouts, SD . BUT V1 can deadlock — three parties lock each other in a ring, all stuck. V2 fix adds three shouts to break the ring: FAILED ("sorry, already promised a better Ugg"), INQUIRE ("you actually cooking, or can give lock back?"), YIELD ("fine, I let go my lock"). V2: up to shouts, SD still .

Tribe Two: pass-the-magic-bone (token)

Suzuki-Kasami — one magic token bone. Hold bone = cook. Want cook? Shout to all; bone-holder toss you the bone IF your ask is FRESH. Bone carries a FIFO queue of waiting Ugg plus (last cook-number done for each Ugg). Each Ugg keep (biggest ask-number ever heard from each Ugg).

  • Ask: ++, shout .
  • Hear : set . If you hold bone, idle, AND (fresh — the very next ask), toss bone to Ugg-i.
  • Done: . Any Ugg-j with , add to . Pop front of , toss bone there.

Cost: (already hold bone) or . SD or . The test throws away OLD stale asks from slow shouts.

Raymond — token on a tree, no shouting to all. Every Ugg has a Holder pointer aiming toward the bone (the root), plus a FIFO queue .

  • Ask: push self on ; if not the holder and was empty, shout REQUEST to Holder (your parent).
  • Middle Ugg hears REQUEST: queue it; if no ask sent up yet, pass REQUEST up to Holder.
  • Root hears REQUEST: send bone toward asker, flip its Holder pointer.
  • Get bone: pop front; if self, cook; else pass bone on and flip Holder. If still not empty, shout REQUEST up again.

Cost: shouts (balanced tree). SD . Danger: everything funnels through the root — root bottleneck.

The big stone-tablet (MEMORIZE)

| Rule | Tribe | Shouts | SD | Watch out | |---|---|---|---|---| | Lamport | non-token | | | need FIFO | | Ricart-Agrawala | non-token | | | no FIFO | | Maekawa V1 | quorum | | | deadlocks | | Maekawa V2 | quorum | up to | | deadlock-free | | Suzuki-Kasami | token | or | or | bone can get lost | | Raymond | token tree | | | root bottleneck |

Why grandfather needs FIFO but grandchild does not

Lamport leans on REQUEST-then-RELEASE order. RELEASE removes a stone that REQUEST first put in the queue. If RELEASE could run PAST an earlier REQUEST (no FIFO), an Ugg tries to remove a stone not queued yet. Broken! Ricart-Agrawala has NO release shout at all — the held-back REPLYs keep the timestamp order by themselves. No FIFO needed.

Ugg warn: no do this!

  • No mix up shout-counts. Lamport , R-A , Maekawa V1 , V2 up to , S-K or , Raymond .
  • No say "R-A needs FIFO." Wrong — R-A's whole beauty is NO FIFO.
  • No forget Lamport needs L1 AND L2 both. Either one alone not enough.
  • No say "Maekawa V1 is deadlock-free." Wrong — V1 deadlocks, V2 fixes it.
  • S-K bone test is , EXACT equal — not bigger, not smaller.

Ugg remember

  • Two tribes: ask-permission (Lamport, R-A, Maekawa) vs pass-the-bone (Suzuki-Kasami, Raymond). Token = fewer shouts, but the bone can be lost or its holder can die.
  • Three promises (safety, liveness, fairness) + throughput . Smaller SD, more dinners.
  • The table is the whole exam: shouts + SD + gotcha for all six rows. Memorize it cold.
  • Lamport: L1+L2, FIFO, . R-A: no FIFO, , deferred REPLY.
  • Maekawa , V1 deadlocks, V2 = FAILED/INQUIRE/YIELD. S-K fresh test . Raymond Holder pointer, , root bottleneck.
End of storyUnit 5 — Distributed Mutual Exclusion · Lamport, Ricart-Agrawala, Maekawa, Suzuki-Kasami, Raymond — Complete Comparison