SlideShare a Scribd company logo
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.)

More Related Content

What's hot

Flow oriented modeling
Flow oriented modelingFlow oriented modeling
Flow oriented modeling
ramyaaswin
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
Ravindra Raju Kolahalam
 
Statistical Software Quality Assurance.pptx
Statistical Software Quality Assurance.pptxStatistical Software Quality Assurance.pptx
Statistical Software Quality Assurance.pptx
KarthigaiSelviS3
 
Distributed Deadlock Detection.ppt
Distributed Deadlock Detection.pptDistributed Deadlock Detection.ppt
Distributed Deadlock Detection.ppt
Babar Kamran Ahmed (LION)
 
resource management
  resource management  resource management
resource management
Ashish Kumar
 
Fuzzy Membership Function
Fuzzy Membership Function Fuzzy Membership Function
Election algorithms
Election algorithmsElection algorithms
Election algorithms
Ankush Kumar
 
Clock synchronization in distributed system
Clock synchronization in distributed systemClock synchronization in distributed system
Clock synchronization in distributed system
Sunita Sahu
 
Selective repeat protocol
Selective repeat protocolSelective repeat protocol
Selective repeat protocol
Manusha Dilan
 
Stream oriented communication
Stream oriented communicationStream oriented communication
Stream oriented communication
Shyama Bhuvanendran
 
File models and file accessing models
File models and file accessing modelsFile models and file accessing models
File models and file accessing models
ishmecse13
 
fault-tolerance-slide.ppt
fault-tolerance-slide.pptfault-tolerance-slide.ppt
fault-tolerance-slide.ppt
Shailendra61
 
Distributed Mutual exclusion algorithms
Distributed Mutual exclusion algorithmsDistributed Mutual exclusion algorithms
Distributed Mutual exclusion algorithms
MNM Jain Engineering College
 
Checkpointing.pptx
Checkpointing.pptxCheckpointing.pptx
Checkpointing.pptx
AzmiNizar1
 
Operating system 34 contiguous allocation
Operating system 34 contiguous allocationOperating system 34 contiguous allocation
Operating system 34 contiguous allocation
Vaibhav Khanna
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
Khushboo Jain
 
Measures of query cost
Measures of query costMeasures of query cost
Measures of query cost
Hitesh Mohapatra
 
Message passing ( in computer science)
Message   passing  ( in   computer  science)Message   passing  ( in   computer  science)
Message passing ( in computer science)
Computer_ at_home
 
Deadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbianDeadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbian
saad symbian
 
Multilevel queue scheduling
Multilevel queue schedulingMultilevel queue scheduling
Multilevel queue scheduling
AditiPawaskar5
 

What's hot (20)

Flow oriented modeling
Flow oriented modelingFlow oriented modeling
Flow oriented modeling
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Statistical Software Quality Assurance.pptx
Statistical Software Quality Assurance.pptxStatistical Software Quality Assurance.pptx
Statistical Software Quality Assurance.pptx
 
Distributed Deadlock Detection.ppt
Distributed Deadlock Detection.pptDistributed Deadlock Detection.ppt
Distributed Deadlock Detection.ppt
 
resource management
  resource management  resource management
resource management
 
Fuzzy Membership Function
Fuzzy Membership Function Fuzzy Membership Function
Fuzzy Membership Function
 
Election algorithms
Election algorithmsElection algorithms
Election algorithms
 
Clock synchronization in distributed system
Clock synchronization in distributed systemClock synchronization in distributed system
Clock synchronization in distributed system
 
Selective repeat protocol
Selective repeat protocolSelective repeat protocol
Selective repeat protocol
 
Stream oriented communication
Stream oriented communicationStream oriented communication
Stream oriented communication
 
File models and file accessing models
File models and file accessing modelsFile models and file accessing models
File models and file accessing models
 
fault-tolerance-slide.ppt
fault-tolerance-slide.pptfault-tolerance-slide.ppt
fault-tolerance-slide.ppt
 
Distributed Mutual exclusion algorithms
Distributed Mutual exclusion algorithmsDistributed Mutual exclusion algorithms
Distributed Mutual exclusion algorithms
 
Checkpointing.pptx
Checkpointing.pptxCheckpointing.pptx
Checkpointing.pptx
 
Operating system 34 contiguous allocation
Operating system 34 contiguous allocationOperating system 34 contiguous allocation
Operating system 34 contiguous allocation
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
 
Measures of query cost
Measures of query costMeasures of query cost
Measures of query cost
 
Message passing ( in computer science)
Message   passing  ( in   computer  science)Message   passing  ( in   computer  science)
Message passing ( in computer science)
 
Deadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbianDeadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbian
 
Multilevel queue scheduling
Multilevel queue schedulingMultilevel queue scheduling
Multilevel queue scheduling
 

Similar to 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
 
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
Dr Sandeep Kumar Poonia
 
Deadlock
DeadlockDeadlock
Deadlock
Mayuri Verma
 
deadlocks.pptx
deadlocks.pptxdeadlocks.pptx
deadlocks.pptx
JOHNZHOU52
 
DeadlockMar21.ppt
DeadlockMar21.pptDeadlockMar21.ppt
DeadlockMar21.ppt
hetrathod001
 
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
LegesseSamuel
 
Ch07 deadlocks
Ch07 deadlocksCh07 deadlocks
Ch07 deadlocks
Nazir Ahmed
 
Deadlock in Real Time operating Systempptx
Deadlock in Real Time operating SystempptxDeadlock in Real Time operating Systempptx
Deadlock in Real Time operating Systempptx
ssuserca5764
 
Module 3 Deadlocks.pptx
Module 3 Deadlocks.pptxModule 3 Deadlocks.pptx
Module 3 Deadlocks.pptx
shreesha16
 
Deadlock (1).ppt
Deadlock (1).pptDeadlock (1).ppt
Deadlock (1).ppt
Nusaike Mufthie
 
Ch7 deadlocks
Ch7   deadlocksCh7   deadlocks
Ch7 deadlocks
Welly Dian Astika
 
Coordination and Agreement .ppt
Coordination and Agreement .pptCoordination and Agreement .ppt
Coordination and Agreement .ppt
SOURAVKUMAR723356
 
Deadlocks Part- I.pdf
Deadlocks Part- I.pdfDeadlocks Part- I.pdf
Deadlocks Part- I.pdf
Harika Pudugosula
 
deadlock and starvation resources allocation.pptx
deadlock and starvation resources allocation.pptxdeadlock and starvation resources allocation.pptx
deadlock and starvation resources allocation.pptx
Saba651353
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
ushabarad142
 
6. Deadlock_1640227623705.pptx
6. Deadlock_1640227623705.pptx6. Deadlock_1640227623705.pptx
6. Deadlock_1640227623705.pptx
shrijanasharma3
 
Deadlocks Part- II.pdf
Deadlocks Part- II.pdfDeadlocks Part- II.pdf
Deadlocks Part- II.pdf
Harika Pudugosula
 
Deadlocks2
Deadlocks2Deadlocks2
Deadlocks2
rizwanaabassi
 
OS UNIT3.pptx
OS UNIT3.pptxOS UNIT3.pptx
OS UNIT3.pptx
DHANABALSUBRAMANIAN
 
Distributed Mutual Exclusion and Distributed Deadlock Detection
Distributed Mutual Exclusion and Distributed Deadlock DetectionDistributed Mutual Exclusion and Distributed Deadlock Detection
Distributed Mutual Exclusion and Distributed Deadlock Detection
SHIKHA GAUTAM
 

Similar to 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 ...
 
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
 
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
 
OS UNIT3.pptx
OS UNIT3.pptxOS UNIT3.pptx
OS UNIT3.pptx
 
Distributed Mutual Exclusion and Distributed Deadlock Detection
Distributed Mutual Exclusion and Distributed Deadlock DetectionDistributed Mutual Exclusion and Distributed Deadlock Detection
Distributed Mutual Exclusion and Distributed Deadlock Detection
 

Recently uploaded

原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
ecqow
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
MadhavJungKarki
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
VANDANAMOHANGOUDA
 
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
sydezfe
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
Prakhyath Rai
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
TIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptxTIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptx
CVCSOfficial
 
Accident detection system project report.pdf
Accident detection system project report.pdfAccident detection system project report.pdf
Accident detection system project report.pdf
Kamal Acharya
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
ijaia
 
Supermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdfSupermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdf
Kamal Acharya
 
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
ijseajournal
 
AI-Based Home Security System : Home security
AI-Based Home Security System : Home securityAI-Based Home Security System : Home security
AI-Based Home Security System : Home security
AIRCC Publishing Corporation
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
aryanpankaj78
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
Prakhyath Rai
 
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
upoux
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
harshapolam10
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
upoux
 

Recently uploaded (20)

原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
 
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
TIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptxTIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptx
 
Accident detection system project report.pdf
Accident detection system project report.pdfAccident detection system project report.pdf
Accident detection system project report.pdf
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Supermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdfSupermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdf
 
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
 
AI-Based Home Security System : Home security
AI-Based Home Security System : Home securityAI-Based Home Security System : Home security
AI-Based Home Security System : Home security
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
 
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
 

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.)