SlideShare a Scribd company logo
6
Most read
11
Most read
14
Most read
Mutual Exclusion in
Distributed Memory Systems
CS4532 Concurrent Programming
Dilum Bandara
Dilum.Bandara@uom.lk
Some slides adapted from U Uthaiyashankar (WSO2) and Rajkumar Buyya’s
Exercise
 Come up with a solution to enforce following
synchronization between 2 threads x & y
 Thread x writes to a file f. Then only thread y should
read from f
 Now suppose x & y are 2 processes on 2
different nodes (assume a shared file system)
 Propose a suitable solution to achieve
synchronization
2
Mutual Exclusion Problems
 Centralized algorithms for mutual exclusion
 Semaphores, Monitors, Condition Variables
 Mutual exclusion in distributed memory systems
 No shared memory
 Usually, no centralized instance similar to OS kernel
that would coordinate access
 Based on asynchronous, usually failure-prone,
network infrastructure
 Need a solution for distributed mutual exclusion,
based solely on message passing
3
Mutual Exclusion Requirements
 Safeness property
 Liveness property
 Ordering
 A fairness issue
 Efficient
4
Source: http://pk.org/417/notes/10-mutex.html
Question from 2013 S7 Paper
 There are monkeys living on 2 very high rocks. The
northern monkeys live on the northern rock that provides
water but no food. Conversely, the southern monkeys
live on the southern rock that provides food but no water.
However, both the northern and southern monkeys have
to eat and to drink!
 There is a small rope between the 2 rocks. The rope can
carry up to MaxOnRope monkeys. Concurrent crossing
in both directions is not possible.
1. What type of a solution would you recommend for this
problem? Briefly explain. [3 marks]
2. Provide a pueudocode to solve the problem. [5 marks]
5
Mutual Exclusion Algorithms
6
Mutual Exclusion
algorithms
Centralized
Locks Semaphores Monitors
Distributed
Contention
Based
Voting schemes
Timestamp
priority based
Controlled
(Token based)
Central
server
Ring
Structure
Tree
Structure
Mutual Exclusion Algorithms (Cont.)
1. Centralized algorithm
2. Decentralized algorithm
3. Token-based algorithm
4. Distributed algorithm
7
1. Centralized Algorithm
 Central server that grants permission to enter
critical section
8
Source: http://lycog.com/distributed-systems/centralized-algorithm-mutual-exclusion-in-distributed-systems/
Central Server Algorithm
 Mutual exclusion requirements
 Safeness property – satisfied
 Liveness property – satisfied
 Ordering – not satisfied
 Due to network delay
 Other concerns
 2 messages per request + 1 message to release
 Resource can’t be accessed until at least for a round
trip time
 Delay between 1 process leaving critical section &
another entering
 Single point of failure 9
2. Decentralized Algorithm
10
2. Decentralized Algorithm (Cont.)
 Use many replicas of resources & many
coordinators
 To enter a critical section, a process sends a
request message to coordinators & awaits reply
 Need majority vote from coordinators
 If denied, back-off & retry later
 Can lead to low utilization, particularly under high
contention
 Avoids problem of single point of failure
11
3. Token-Based Algorithm
 Pass a token around
 Whoever having token has exclusive access to
shared resource
 Examples, token ring
12
Source: http://lycog.com/distributed-systems/token-ring-mutual-exclusion-in-distributed-systems/
Ring-Based Algorithm
 Mutual exclusion requirements
 Safeness property – satisfied
 Liveness property – satisfied
 Ordering – not satisfied
 Follow ring order, not order requested by processes
 Other concerns
 Token passing
 Worst case waiting time O(N)
 N – no of processes in the ring
 Delay between 1 process leaving critical section &
another entering is O(N)
13
4. Distributed Algorithm
 By Lamport in 1978, Improved by Ricart & Agrawala in 1981
14
Source: http://lycog.com/distributed-systems/distributed-algorithm-mutual-exclusion-distributed-systems/
Distributed Algorithm
 Mutual exclusion requirements
 Safeness property – satisfied
 Liveness property – satisfied
 Ordering – satisfied
 Events are in total order
 Other concerns
 High overhead
 Gaining entry requires 2(N-1) messages per request
 N – 1 to multicast request followed by N – 1 replies
 Resource can’t be accessed until at least for a round
trip time
 Delay between 1 process leaving critical section &
another entering is 1 message 15
Distributed Algorithm (Cont.)
 N points of failures
 Before granting access each process needs to reply
 If 1 process failed?
 Probability of failure p vs. Np
 N bottlenecks
 Each process need to respond to messages from all
other processes
16
Mutual Exclusion Algorithm
Comparison
 Comparison assumes that messages are passed
sequentially (sent 1 after another) over a network
17
Contention vs. Token Based
Contention
 Competition among
processes
 May need to retry
repeatedly
 No token
 Voting improves fault
tolerance
 What if no majority?
 More complicated to
implement
Token
 Avoid deadlocks
 Avoid starvation by
efficient organization of
processes
 Lost token?
 How to create a new one?
 How to create only 1
token?
18

More Related Content

What's hot (20)

PDF
CS9222 ADVANCED OPERATING SYSTEMS
Kathirvel Ayyaswamy
 
PPTX
Inter Process Communication
Adeel Rasheed
 
PPTX
Media Access Control (MAC Layer)
Meenakshi Paul
 
PPT
Distributed File Systems
Maurvi04
 
PPT
File replication
Klawal13
 
PPT
Process Management-Process Migration
MNM Jain Engineering College
 
PPT
Advanced Operating System Lecture Notes
Anirudhan Guru
 
PPT
Web and http computer network
Anil Pokhrel
 
PPTX
Deadlock- Operating System
Rajan Shah
 
PPT
clock synchronization in Distributed System
Harshita Ved
 
PDF
Storage organization and stack allocation of space
Muhammad Haroon
 
PPTX
Media Access Control
VijayaLakshmi514
 
PDF
CS9222 ADVANCED OPERATING SYSTEMS
Kathirvel Ayyaswamy
 
PDF
Heuristic Search in Artificial Intelligence | Heuristic Function in AI | Admi...
RahulSharma4566
 
PPT
distributed shared memory
Ashish Kumar
 
PPT
Logical Clocks (Distributed computing)
Sri Prasanna
 
PDF
Inter-Process Communication in distributed systems
Aya Mahmoud
 
PPTX
Message and Stream Oriented Communication
Dilum Bandara
 
PPT
process management
Ashish Kumar
 
PPTX
distributed Computing system model
Harshad Umredkar
 
CS9222 ADVANCED OPERATING SYSTEMS
Kathirvel Ayyaswamy
 
Inter Process Communication
Adeel Rasheed
 
Media Access Control (MAC Layer)
Meenakshi Paul
 
Distributed File Systems
Maurvi04
 
File replication
Klawal13
 
Process Management-Process Migration
MNM Jain Engineering College
 
Advanced Operating System Lecture Notes
Anirudhan Guru
 
Web and http computer network
Anil Pokhrel
 
Deadlock- Operating System
Rajan Shah
 
clock synchronization in Distributed System
Harshita Ved
 
Storage organization and stack allocation of space
Muhammad Haroon
 
Media Access Control
VijayaLakshmi514
 
CS9222 ADVANCED OPERATING SYSTEMS
Kathirvel Ayyaswamy
 
Heuristic Search in Artificial Intelligence | Heuristic Function in AI | Admi...
RahulSharma4566
 
distributed shared memory
Ashish Kumar
 
Logical Clocks (Distributed computing)
Sri Prasanna
 
Inter-Process Communication in distributed systems
Aya Mahmoud
 
Message and Stream Oriented Communication
Dilum Bandara
 
process management
Ashish Kumar
 
distributed Computing system model
Harshad Umredkar
 

Similar to Mutual Exclusion in Distributed Memory Systems (20)

PDF
DC Lecture 04 and 05 Mutual Excution and Election Algorithms.pdf
LegesseSamuel
 
PPT
dos mutual exclusion algos
Akhil Sharma
 
PPT
Mutual-Exclusion Algorithm.ppt
ShikhaManrai1
 
PPTX
Distributed Mutual Exclusion and Distributed Deadlock Detection
SHIKHA GAUTAM
 
PDF
Mutual exclusion
DheerajPrajapat5
 
PPTX
Module 3 (1).pptx
AmalMR4
 
PPTX
distributed system ppt presentation in cs
Anonymous9etQKwW
 
PDF
Chapter9.pdf
AzmiNizar1
 
PDF
Comparative Study of Mutual Exclusion Algorithms in Distributed Systems
IJERA Editor
 
PDF
Chapter 15 slides Distributed System Presentation
Nehal668249
 
PPTX
Mutual Exclusion using Peterson's Algorithm
Souvik Roy
 
PDF
7. Mutual Exclusion
Prajakta Rane
 
PDF
A New Function-based Framework for Classification and Evaluation of Mutual Ex...
CSCJournals
 
PDF
Analysis of mutual exclusion algorithms with the significance and need of ele...
Govt. P.G. College Dharamshala
 
PDF
Chapter 11d coordination agreement
AbDul ThaYyal
 
PPT
Coordination and Agreement .ppt
SOURAVKUMAR723356
 
PDF
Unit_5_Distributed Mutual Exclusion.pdf
Dr.Somnath Thigale
 
PDF
Unit 3 Part 1.pdf distribution computing
monishiisha04
 
PDF
Analysis of roucairol and carvalho approach in
eSAT Publishing House
 
PPTX
mutual exclusion algos 16619.4 pptx cloud computing
9921103075
 
DC Lecture 04 and 05 Mutual Excution and Election Algorithms.pdf
LegesseSamuel
 
dos mutual exclusion algos
Akhil Sharma
 
Mutual-Exclusion Algorithm.ppt
ShikhaManrai1
 
Distributed Mutual Exclusion and Distributed Deadlock Detection
SHIKHA GAUTAM
 
Mutual exclusion
DheerajPrajapat5
 
Module 3 (1).pptx
AmalMR4
 
distributed system ppt presentation in cs
Anonymous9etQKwW
 
Chapter9.pdf
AzmiNizar1
 
Comparative Study of Mutual Exclusion Algorithms in Distributed Systems
IJERA Editor
 
Chapter 15 slides Distributed System Presentation
Nehal668249
 
Mutual Exclusion using Peterson's Algorithm
Souvik Roy
 
7. Mutual Exclusion
Prajakta Rane
 
A New Function-based Framework for Classification and Evaluation of Mutual Ex...
CSCJournals
 
Analysis of mutual exclusion algorithms with the significance and need of ele...
Govt. P.G. College Dharamshala
 
Chapter 11d coordination agreement
AbDul ThaYyal
 
Coordination and Agreement .ppt
SOURAVKUMAR723356
 
Unit_5_Distributed Mutual Exclusion.pdf
Dr.Somnath Thigale
 
Unit 3 Part 1.pdf distribution computing
monishiisha04
 
Analysis of roucairol and carvalho approach in
eSAT Publishing House
 
mutual exclusion algos 16619.4 pptx cloud computing
9921103075
 
Ad

More from Dilum Bandara (20)

PPTX
Designing for Multiple Blockchains in Industry Ecosystems
Dilum Bandara
 
PPTX
Introduction to Machine Learning
Dilum Bandara
 
PPTX
Time Series Analysis and Forecasting in Practice
Dilum Bandara
 
PPTX
Introduction to Dimension Reduction with PCA
Dilum Bandara
 
PPTX
Introduction to Descriptive & Predictive Analytics
Dilum Bandara
 
PPTX
Introduction to Concurrent Data Structures
Dilum Bandara
 
PPTX
Hard to Paralelize Problems: Matrix-Vector and Matrix-Matrix
Dilum Bandara
 
PPTX
Introduction to Map-Reduce Programming with Hadoop
Dilum Bandara
 
PPTX
Embarrassingly/Delightfully Parallel Problems
Dilum Bandara
 
PPTX
Introduction to Warehouse-Scale Computers
Dilum Bandara
 
PPTX
Introduction to Thread Level Parallelism
Dilum Bandara
 
PPTX
CPU Memory Hierarchy and Caching Techniques
Dilum Bandara
 
PPTX
Data-Level Parallelism in Microprocessors
Dilum Bandara
 
PDF
Instruction Level Parallelism – Hardware Techniques
Dilum Bandara
 
PPTX
Instruction Level Parallelism – Compiler Techniques
Dilum Bandara
 
PPTX
CPU Pipelining and Hazards - An Introduction
Dilum Bandara
 
PPTX
Advanced Computer Architecture – An Introduction
Dilum Bandara
 
PPTX
High Performance Networking with Advanced TCP
Dilum Bandara
 
PPTX
Introduction to Content Delivery Networks
Dilum Bandara
 
PPTX
Peer-to-Peer Networking Systems and Streaming
Dilum Bandara
 
Designing for Multiple Blockchains in Industry Ecosystems
Dilum Bandara
 
Introduction to Machine Learning
Dilum Bandara
 
Time Series Analysis and Forecasting in Practice
Dilum Bandara
 
Introduction to Dimension Reduction with PCA
Dilum Bandara
 
Introduction to Descriptive & Predictive Analytics
Dilum Bandara
 
Introduction to Concurrent Data Structures
Dilum Bandara
 
Hard to Paralelize Problems: Matrix-Vector and Matrix-Matrix
Dilum Bandara
 
Introduction to Map-Reduce Programming with Hadoop
Dilum Bandara
 
Embarrassingly/Delightfully Parallel Problems
Dilum Bandara
 
Introduction to Warehouse-Scale Computers
Dilum Bandara
 
Introduction to Thread Level Parallelism
Dilum Bandara
 
CPU Memory Hierarchy and Caching Techniques
Dilum Bandara
 
Data-Level Parallelism in Microprocessors
Dilum Bandara
 
Instruction Level Parallelism – Hardware Techniques
Dilum Bandara
 
Instruction Level Parallelism – Compiler Techniques
Dilum Bandara
 
CPU Pipelining and Hazards - An Introduction
Dilum Bandara
 
Advanced Computer Architecture – An Introduction
Dilum Bandara
 
High Performance Networking with Advanced TCP
Dilum Bandara
 
Introduction to Content Delivery Networks
Dilum Bandara
 
Peer-to-Peer Networking Systems and Streaming
Dilum Bandara
 
Ad

Recently uploaded (20)

PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 

Mutual Exclusion in Distributed Memory Systems

  • 1. Mutual Exclusion in Distributed Memory Systems CS4532 Concurrent Programming Dilum Bandara [email protected] Some slides adapted from U Uthaiyashankar (WSO2) and Rajkumar Buyya’s
  • 2. Exercise  Come up with a solution to enforce following synchronization between 2 threads x & y  Thread x writes to a file f. Then only thread y should read from f  Now suppose x & y are 2 processes on 2 different nodes (assume a shared file system)  Propose a suitable solution to achieve synchronization 2
  • 3. Mutual Exclusion Problems  Centralized algorithms for mutual exclusion  Semaphores, Monitors, Condition Variables  Mutual exclusion in distributed memory systems  No shared memory  Usually, no centralized instance similar to OS kernel that would coordinate access  Based on asynchronous, usually failure-prone, network infrastructure  Need a solution for distributed mutual exclusion, based solely on message passing 3
  • 4. Mutual Exclusion Requirements  Safeness property  Liveness property  Ordering  A fairness issue  Efficient 4 Source: http://pk.org/417/notes/10-mutex.html
  • 5. Question from 2013 S7 Paper  There are monkeys living on 2 very high rocks. The northern monkeys live on the northern rock that provides water but no food. Conversely, the southern monkeys live on the southern rock that provides food but no water. However, both the northern and southern monkeys have to eat and to drink!  There is a small rope between the 2 rocks. The rope can carry up to MaxOnRope monkeys. Concurrent crossing in both directions is not possible. 1. What type of a solution would you recommend for this problem? Briefly explain. [3 marks] 2. Provide a pueudocode to solve the problem. [5 marks] 5
  • 6. Mutual Exclusion Algorithms 6 Mutual Exclusion algorithms Centralized Locks Semaphores Monitors Distributed Contention Based Voting schemes Timestamp priority based Controlled (Token based) Central server Ring Structure Tree Structure
  • 7. Mutual Exclusion Algorithms (Cont.) 1. Centralized algorithm 2. Decentralized algorithm 3. Token-based algorithm 4. Distributed algorithm 7
  • 8. 1. Centralized Algorithm  Central server that grants permission to enter critical section 8 Source: http://lycog.com/distributed-systems/centralized-algorithm-mutual-exclusion-in-distributed-systems/
  • 9. Central Server Algorithm  Mutual exclusion requirements  Safeness property – satisfied  Liveness property – satisfied  Ordering – not satisfied  Due to network delay  Other concerns  2 messages per request + 1 message to release  Resource can’t be accessed until at least for a round trip time  Delay between 1 process leaving critical section & another entering  Single point of failure 9
  • 11. 2. Decentralized Algorithm (Cont.)  Use many replicas of resources & many coordinators  To enter a critical section, a process sends a request message to coordinators & awaits reply  Need majority vote from coordinators  If denied, back-off & retry later  Can lead to low utilization, particularly under high contention  Avoids problem of single point of failure 11
  • 12. 3. Token-Based Algorithm  Pass a token around  Whoever having token has exclusive access to shared resource  Examples, token ring 12 Source: http://lycog.com/distributed-systems/token-ring-mutual-exclusion-in-distributed-systems/
  • 13. Ring-Based Algorithm  Mutual exclusion requirements  Safeness property – satisfied  Liveness property – satisfied  Ordering – not satisfied  Follow ring order, not order requested by processes  Other concerns  Token passing  Worst case waiting time O(N)  N – no of processes in the ring  Delay between 1 process leaving critical section & another entering is O(N) 13
  • 14. 4. Distributed Algorithm  By Lamport in 1978, Improved by Ricart & Agrawala in 1981 14 Source: http://lycog.com/distributed-systems/distributed-algorithm-mutual-exclusion-distributed-systems/
  • 15. Distributed Algorithm  Mutual exclusion requirements  Safeness property – satisfied  Liveness property – satisfied  Ordering – satisfied  Events are in total order  Other concerns  High overhead  Gaining entry requires 2(N-1) messages per request  N – 1 to multicast request followed by N – 1 replies  Resource can’t be accessed until at least for a round trip time  Delay between 1 process leaving critical section & another entering is 1 message 15
  • 16. Distributed Algorithm (Cont.)  N points of failures  Before granting access each process needs to reply  If 1 process failed?  Probability of failure p vs. Np  N bottlenecks  Each process need to respond to messages from all other processes 16
  • 17. Mutual Exclusion Algorithm Comparison  Comparison assumes that messages are passed sequentially (sent 1 after another) over a network 17
  • 18. Contention vs. Token Based Contention  Competition among processes  May need to retry repeatedly  No token  Voting improves fault tolerance  What if no majority?  More complicated to implement Token  Avoid deadlocks  Avoid starvation by efficient organization of processes  Lost token?  How to create a new one?  How to create only 1 token? 18

Editor's Notes

  • #3: Use send() & receive() discussed in MPI class
  • #18: m – no of coordinators k – no of attempts Inf in token ring – as token may get passed without any one wanting it
  • #19: If no majority – one of the processes can be asked to change its vote