SlideShare una empresa de Scribd logo
1 de 24
Page 1
Page 1
Mutual Exclusion*
Distributed Systems
Prepared By:
Er. Shikha Manrai
Page 2
Mutual Exclusion?
• A condition in which there is a set of
processes, only one of which is able to
access a given resource or perform a given
function at any time
Page 3
Centralized Systems
Mutual exclusion via:
– Test & set
– Semaphores
– Messages
– Monitors
Page 4
Distributed Mutual Exclusion
• Assume there is agreement on how a resource
is identified
– Pass identifier with requests
• Create an algorithm to allow a process to
obtain exclusive access to a resource
Page 5
Distributed Mutual Exclusion
• Centralized Algorithm
• Token Ring Algorithm
• Distributed Algorithm
• Decentralized Algorithm
Page 6
Centralized algorithm
• Mimic single processor system
• One process elected as coordinator
P
C
request(R)
grant(R)
1. Request resource
2. Wait for response
3. Receive grant
4. access resource
5. Release resource release(R)
Page 7
Centralized algorithm
If another process claimed resource:
– Coordinator does not reply until release
– Maintain queue
• Service requests in FIFO order
P0
C
request(R)
grant(R)
release(R) P1
P2
request(R)
Queue
P1
request(R)
P2
grant(R)
Page 8
Centralized algorithm
Benefits
• Fair
– All requests processed in order
• Easy to implement, understand, verify
Problems
• Process cannot distinguish being blocked from
a dead coordinator
• Centralized server can be a bottleneck
Page 9
Token Ring algorithm
Assume known group of processes
– Some ordering can be imposed on group
– Construct logical ring in software
– Process communicates with neighbor
P0
P1
P2
P3
P4
P5
Page 10
Token Ring algorithm
• Initialization
– Process 0 gets token for resource R
• Token circulates around ring
– From Pi to P(i+1)mod N
• When process acquires token
– Checks to see if it needs to enter critical section
– If no, send token to neighbor
– If yes, access resource
• Hold token until done
P0
P1
P2
P3
P4
P5
token(R)
Page 11
Token Ring algorithm
• Only one process at a time has token
– Mutual exclusion guaranteed
• Order well-defined
– Starvation cannot occur
• If token is lost (e.g. process died)
– It will have to be regenerated
• Does not guarantee FIFO order
Page 12
Ricart & Agrawala algorithm
• Distributed algorithm using reliable multicast
and logical clocks
• Process wants to enter critical section:
– Compose message containing:
• Identifier (machine ID, process ID)
• Name of resource
• Timestamp (totally-ordered Lamport)
– Send request to all processes in group
– Wait until everyone gives permission
– Enter critical section / use resource
Page 13
Ricart & Agrawala algorithm
• When process receives request:
– If receiver not interested:
• Send OK to sender
– If receiver is in critical section
• Do not reply; add request to queue
– If receiver just sent a request as well:
• Compare timestamps: received & sent messages
• Earliest wins
• If receiver is loser, send OK
• If receiver is winner, do not reply, queue
• When done with critical section
– Send OK to all queued requests
Page 14
Ricart & Agrawala algorithm
• N points of failure
• A lot of messaging traffic
• Demonstrates that a fully distributed
algorithm is possible
Page 15
Lamport’s Mutual Exclusion
Each process maintains request queue
– Contains mutual exclusion requests
Requesting critical section:
– Process Pi sends request(i, Ti) to all nodes
– Places request on its own queue
– When a process Pj receives
a request, it returns a timestamped ack
Lamport time
Page 16
Lamport’s Mutual Exclusion
Entering critical section (accessing resource):
– Pi received a message (ack or release) from every
other process with a timestamp larger than Ti
– Pi’s request has the earliest timestamp in its queue
Difference from Ricart-Agrawala:
– Everyone responds … always - no hold-back
– Process decides to go based on whether its
request is the earliest in its queue
Page 17
Lamport’s Mutual Exclusion
Releasing critical section:
– Remove request from its own queue
– Send a timestamped release message
– When a process receives a release message
• Removes request for that process from its queue
• This may cause its own entry have the earliest timestamp in
the queue, enabling it to access the critical section
Characteristics of Decentralized
Algorithms
 No machine has complete information about the system state
 Machines make decisions based only on local information
 Failure of one machine does not ruin the algorithm
 Three is no implicit assumption that a global clock exists
Page 19
Decentralized Algorithm
• Based on the Distributed Hash Table (DHT)
system structure previously introduced
– Peer-to-peer
– Object names are hashed to find the successor
node that will store them
• Here, we assume that n replicas of each
object are stored
Page 20
Placing the Replicas
• The resource is known by a unique name:
rname
– Replicas: rname-0, rname-I, …, rname-(n-1)
– rname-i is stored at succ(rname-i), where names
and site names are hashed as before
– If a process knows the name of the resource it
wishes to access, it also can generate the hash
keys that are used to locate all the replicas
Page 21
The Decentralized Algorithm
• Every replica has a coordinator that controls
access to it (the coordinator is the node that
stores it)
• For a process to use the resource it must
receive permission from m > n/2 coordinators
• This guarantees exclusive access as long as a
coordinator only grants access to one process
at a time
Page 22
The Decentralized Algorithm
• The coordinator notifies the requester when
it has been denied access as well as when it is
granted
– Requester must “count the votes”, and decide
whether or not overall permission has been granted
or denied
• If a process (requester) gets fewer than m
votes it will wait for a random time and then
ask again
Page 23
Analysis
• If a resource is in high demand, multiple
requests will be generated
• It’s possible that processes will wait a long
time to get permission
• Deadlock?
• Resource usage drops
Page 24
Analysis
• More robust than the central coordinator
approach and the distributed approaches. If
one coordinator goes down others are
available.
– If a coordinator fails and resets then it will not
remember having granted access to one requestor,
and may then give access to another. According to
the authors, it is highly unlikely that this will lead
to a violation of mutual exclusion. (See the text
for a probabilistic argument.)

Más contenido relacionado

La actualidad más candente

Lecture 16 memory bounded search
Lecture 16 memory bounded searchLecture 16 memory bounded search
Lecture 16 memory bounded searchHema Kashyap
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonkanikkk
 
Directed Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksDirected Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksMohammad Vaseem Akaram
 
Network security cryptographic hash function
Network security  cryptographic hash functionNetwork security  cryptographic hash function
Network security cryptographic hash functionMijanur Rahman Milon
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languagesSOMNATHMORE2
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithmMohd Arif
 
Heuristic search
Heuristic searchHeuristic search
Heuristic searchNivethaS35
 
Distributed system lamport's and vector algorithm
Distributed system lamport's and vector algorithmDistributed system lamport's and vector algorithm
Distributed system lamport's and vector algorithmpinki soni
 
Optimal binary search tree
Optimal binary search treeOptimal binary search tree
Optimal binary search treeKavya P
 
Local search algorithm
Local search algorithmLocal search algorithm
Local search algorithmMegha Sharma
 
Hill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligenceHill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligencesandeep54552
 
3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cflSampath Kumar S
 

La actualidad más candente (20)

Optimal binary search tree dynamic programming
Optimal binary search tree   dynamic programmingOptimal binary search tree   dynamic programming
Optimal binary search tree dynamic programming
 
Lecture 16 memory bounded search
Lecture 16 memory bounded searchLecture 16 memory bounded search
Lecture 16 memory bounded search
 
Disjoint sets
Disjoint setsDisjoint sets
Disjoint sets
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilon
 
Directed Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksDirected Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocks
 
Chapter18
Chapter18Chapter18
Chapter18
 
MACRO PROCESSOR
MACRO PROCESSORMACRO PROCESSOR
MACRO PROCESSOR
 
Process Management-Process Migration
Process Management-Process MigrationProcess Management-Process Migration
Process Management-Process Migration
 
Network security cryptographic hash function
Network security  cryptographic hash functionNetwork security  cryptographic hash function
Network security cryptographic hash function
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languages
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
Heuristic search
Heuristic searchHeuristic search
Heuristic search
 
Distributed system lamport's and vector algorithm
Distributed system lamport's and vector algorithmDistributed system lamport's and vector algorithm
Distributed system lamport's and vector algorithm
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Optimal binary search tree
Optimal binary search treeOptimal binary search tree
Optimal binary search tree
 
Unit 4 sp macro
Unit 4 sp macroUnit 4 sp macro
Unit 4 sp macro
 
Local search algorithm
Local search algorithmLocal search algorithm
Local search algorithm
 
Hill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligenceHill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligence
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
 
3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl
 

Similar a Mutual-Exclusion Algorithm.ppt

Implementation of Election Algorithm of Distributed Systems in Client-Server ...
Implementation of Election Algorithm of Distributed Systems in Client-Server ...Implementation of Election Algorithm of Distributed Systems in Client-Server ...
Implementation of Election Algorithm of Distributed Systems in Client-Server ...Mushfekur Rahman
 
Mutual Exclusion Election (Distributed computing)
Mutual Exclusion Election (Distributed computing)Mutual Exclusion Election (Distributed computing)
Mutual Exclusion Election (Distributed computing)Sri Prasanna
 
8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating SystemsDr Sandeep Kumar Poonia
 
deadlocks.pptx
deadlocks.pptxdeadlocks.pptx
deadlocks.pptxJOHNZHOU52
 
DC Lecture 04 and 05 Mutual Excution and Election Algorithms.pdf
DC Lecture 04 and 05 Mutual Excution and Election Algorithms.pdfDC Lecture 04 and 05 Mutual Excution and Election Algorithms.pdf
DC Lecture 04 and 05 Mutual Excution and Election Algorithms.pdfLegesseSamuel
 
Deadlock in Real Time operating Systempptx
Deadlock in Real Time operating SystempptxDeadlock in Real Time operating Systempptx
Deadlock in Real Time operating Systempptxssuserca5764
 
Module 3 Deadlocks.pptx
Module 3 Deadlocks.pptxModule 3 Deadlocks.pptx
Module 3 Deadlocks.pptxshreesha16
 
Coordination and Agreement .ppt
Coordination and Agreement .pptCoordination and Agreement .ppt
Coordination and Agreement .pptSOURAVKUMAR723356
 
deadlock and starvation resources allocation.pptx
deadlock and starvation resources allocation.pptxdeadlock and starvation resources allocation.pptx
deadlock and starvation resources allocation.pptxSaba651353
 
6. Deadlock_1640227623705.pptx
6. Deadlock_1640227623705.pptx6. Deadlock_1640227623705.pptx
6. Deadlock_1640227623705.pptxshrijanasharma3
 

Similar a Mutual-Exclusion Algorithm.ppt (20)

Implementation of Election Algorithm of Distributed Systems in Client-Server ...
Implementation of Election Algorithm of Distributed Systems in Client-Server ...Implementation of Election Algorithm of Distributed Systems in Client-Server ...
Implementation of Election Algorithm of Distributed Systems in Client-Server ...
 
Mutual Exclusion Election (Distributed computing)
Mutual Exclusion Election (Distributed computing)Mutual Exclusion Election (Distributed computing)
Mutual Exclusion Election (Distributed computing)
 
8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems
 
Deadlock
DeadlockDeadlock
Deadlock
 
deadlocks.pptx
deadlocks.pptxdeadlocks.pptx
deadlocks.pptx
 
DeadlockMar21.ppt
DeadlockMar21.pptDeadlockMar21.ppt
DeadlockMar21.ppt
 
DC Lecture 04 and 05 Mutual Excution and Election Algorithms.pdf
DC Lecture 04 and 05 Mutual Excution and Election Algorithms.pdfDC Lecture 04 and 05 Mutual Excution and Election Algorithms.pdf
DC Lecture 04 and 05 Mutual Excution and Election Algorithms.pdf
 
Ch07 deadlocks
Ch07 deadlocksCh07 deadlocks
Ch07 deadlocks
 
Deadlock in Real Time operating Systempptx
Deadlock in Real Time operating SystempptxDeadlock in Real Time operating Systempptx
Deadlock in Real Time operating Systempptx
 
Module 3 Deadlocks.pptx
Module 3 Deadlocks.pptxModule 3 Deadlocks.pptx
Module 3 Deadlocks.pptx
 
Deadlock (1).ppt
Deadlock (1).pptDeadlock (1).ppt
Deadlock (1).ppt
 
Ch7 deadlocks
Ch7   deadlocksCh7   deadlocks
Ch7 deadlocks
 
Coordination and Agreement .ppt
Coordination and Agreement .pptCoordination and Agreement .ppt
Coordination and Agreement .ppt
 
Distributed Deadlock Detection.ppt
Distributed Deadlock Detection.pptDistributed Deadlock Detection.ppt
Distributed Deadlock Detection.ppt
 
Deadlocks Part- I.pdf
Deadlocks Part- I.pdfDeadlocks Part- I.pdf
Deadlocks Part- I.pdf
 
deadlock and starvation resources allocation.pptx
deadlock and starvation resources allocation.pptxdeadlock and starvation resources allocation.pptx
deadlock and starvation resources allocation.pptx
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
6. Deadlock_1640227623705.pptx
6. Deadlock_1640227623705.pptx6. Deadlock_1640227623705.pptx
6. Deadlock_1640227623705.pptx
 
Deadlocks Part- II.pdf
Deadlocks Part- II.pdfDeadlocks Part- II.pdf
Deadlocks Part- II.pdf
 
Deadlocks2
Deadlocks2Deadlocks2
Deadlocks2
 

Último

Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Internet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxInternet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxVelmuruganTECE
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadaditya806802
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...Amil Baba Dawood bangali
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESNarmatha D
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 

Último (20)

Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Internet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxInternet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptx
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasad
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIES
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 

Mutual-Exclusion Algorithm.ppt

  • 1. Page 1 Page 1 Mutual Exclusion* Distributed Systems Prepared By: Er. Shikha Manrai
  • 2. Page 2 Mutual Exclusion? • A condition in which there is a set of processes, only one of which is able to access a given resource or perform a given function at any time
  • 3. Page 3 Centralized Systems Mutual exclusion via: – Test & set – Semaphores – Messages – Monitors
  • 4. Page 4 Distributed Mutual Exclusion • Assume there is agreement on how a resource is identified – Pass identifier with requests • Create an algorithm to allow a process to obtain exclusive access to a resource
  • 5. Page 5 Distributed Mutual Exclusion • Centralized Algorithm • Token Ring Algorithm • Distributed Algorithm • Decentralized Algorithm
  • 6. Page 6 Centralized algorithm • Mimic single processor system • One process elected as coordinator P C request(R) grant(R) 1. Request resource 2. Wait for response 3. Receive grant 4. access resource 5. Release resource release(R)
  • 7. Page 7 Centralized algorithm If another process claimed resource: – Coordinator does not reply until release – Maintain queue • Service requests in FIFO order P0 C request(R) grant(R) release(R) P1 P2 request(R) Queue P1 request(R) P2 grant(R)
  • 8. Page 8 Centralized algorithm Benefits • Fair – All requests processed in order • Easy to implement, understand, verify Problems • Process cannot distinguish being blocked from a dead coordinator • Centralized server can be a bottleneck
  • 9. Page 9 Token Ring algorithm Assume known group of processes – Some ordering can be imposed on group – Construct logical ring in software – Process communicates with neighbor P0 P1 P2 P3 P4 P5
  • 10. Page 10 Token Ring algorithm • Initialization – Process 0 gets token for resource R • Token circulates around ring – From Pi to P(i+1)mod N • When process acquires token – Checks to see if it needs to enter critical section – If no, send token to neighbor – If yes, access resource • Hold token until done P0 P1 P2 P3 P4 P5 token(R)
  • 11. Page 11 Token Ring algorithm • Only one process at a time has token – Mutual exclusion guaranteed • Order well-defined – Starvation cannot occur • If token is lost (e.g. process died) – It will have to be regenerated • Does not guarantee FIFO order
  • 12. Page 12 Ricart & Agrawala algorithm • Distributed algorithm using reliable multicast and logical clocks • Process wants to enter critical section: – Compose message containing: • Identifier (machine ID, process ID) • Name of resource • Timestamp (totally-ordered Lamport) – Send request to all processes in group – Wait until everyone gives permission – Enter critical section / use resource
  • 13. Page 13 Ricart & Agrawala algorithm • When process receives request: – If receiver not interested: • Send OK to sender – If receiver is in critical section • Do not reply; add request to queue – If receiver just sent a request as well: • Compare timestamps: received & sent messages • Earliest wins • If receiver is loser, send OK • If receiver is winner, do not reply, queue • When done with critical section – Send OK to all queued requests
  • 14. Page 14 Ricart & Agrawala algorithm • N points of failure • A lot of messaging traffic • Demonstrates that a fully distributed algorithm is possible
  • 15. Page 15 Lamport’s Mutual Exclusion Each process maintains request queue – Contains mutual exclusion requests Requesting critical section: – Process Pi sends request(i, Ti) to all nodes – Places request on its own queue – When a process Pj receives a request, it returns a timestamped ack Lamport time
  • 16. Page 16 Lamport’s Mutual Exclusion Entering critical section (accessing resource): – Pi received a message (ack or release) from every other process with a timestamp larger than Ti – Pi’s request has the earliest timestamp in its queue Difference from Ricart-Agrawala: – Everyone responds … always - no hold-back – Process decides to go based on whether its request is the earliest in its queue
  • 17. Page 17 Lamport’s Mutual Exclusion Releasing critical section: – Remove request from its own queue – Send a timestamped release message – When a process receives a release message • Removes request for that process from its queue • This may cause its own entry have the earliest timestamp in the queue, enabling it to access the critical section
  • 18. Characteristics of Decentralized Algorithms  No machine has complete information about the system state  Machines make decisions based only on local information  Failure of one machine does not ruin the algorithm  Three is no implicit assumption that a global clock exists
  • 19. Page 19 Decentralized Algorithm • Based on the Distributed Hash Table (DHT) system structure previously introduced – Peer-to-peer – Object names are hashed to find the successor node that will store them • Here, we assume that n replicas of each object are stored
  • 20. Page 20 Placing the Replicas • The resource is known by a unique name: rname – Replicas: rname-0, rname-I, …, rname-(n-1) – rname-i is stored at succ(rname-i), where names and site names are hashed as before – If a process knows the name of the resource it wishes to access, it also can generate the hash keys that are used to locate all the replicas
  • 21. Page 21 The Decentralized Algorithm • Every replica has a coordinator that controls access to it (the coordinator is the node that stores it) • For a process to use the resource it must receive permission from m > n/2 coordinators • This guarantees exclusive access as long as a coordinator only grants access to one process at a time
  • 22. Page 22 The Decentralized Algorithm • The coordinator notifies the requester when it has been denied access as well as when it is granted – Requester must “count the votes”, and decide whether or not overall permission has been granted or denied • If a process (requester) gets fewer than m votes it will wait for a random time and then ask again
  • 23. Page 23 Analysis • If a resource is in high demand, multiple requests will be generated • It’s possible that processes will wait a long time to get permission • Deadlock? • Resource usage drops
  • 24. Page 24 Analysis • More robust than the central coordinator approach and the distributed approaches. If one coordinator goes down others are available. – If a coordinator fails and resets then it will not remember having granted access to one requestor, and may then give access to another. According to the authors, it is highly unlikely that this will lead to a violation of mutual exclusion. (See the text for a probabilistic argument.)