Distributed System Lecture 6
Distributed System Lecture 6
Prof. D. S. Yadav
Department of Computer Science 1
IET Lucknow
Distributed Computing: Principles, Algorithms, and Systems
INTRODUCTION
Mutual exclusion: Concurrent access of processes to a
shared resource or data is executed in mutually
exclusive manner.
Only one process is allowed to execute the critical
section (CS) at any given time.
In a distributed system, shared variables (semaphores)
or a local kernel cannot be used to implement mutual
exclusion.
Message passing is the sole means for implementing
distributed mutual exclusion.
2
Distributed Computing: Principles, Algorithms, and Systems
INTRODUCTION
3
Distributed Computing: Principles, Algorithms, and Systems
INTRODUCTION
(called a quorum).
◮ Any two quorums contain a common site.
◮ This common site is responsible to make sure that only one request
4
Distributed Computing: Principles, Algorithms, and Systems
PRELIMINARIES
System Model
The system consists of N sites, S1, S2, ..., SN .
We assume that a single process is running on each site. The process at
site
Si is denoted by pi .
A site can be in one of the following three states:
requesting the CS,
executing the CS,
or neither requesting nor executing the CS (i.e., idle).
In the ‘requesting the CS’ state, the site is blocked and can not make
further requests for the CS. In the ‘idle’ state, the site is executing outside
the CS.
In token-based algorithms, a site can also be in a state where a site
holding the token is executing outside the CS (called the idle token state).
At any instant, a site may have several pending requests for CS. A site
queues up these requests and serves them one at a time.
5
Distributed Computing: Principles, Algorithms, and Systems
REQUIREMENTS
6
Distributed Computing: Principles, Algorithms, and Systems
PERFORMANCE METRICS
The performance is generally measured by the following four
metrics:
Message complexity: The number of messages required per CS
execution by a site.
Synchronization delay: After a site leaves the CS, it is the time
required and before the next site enters the CS.
Last site exits the CS
Next site enters the CS
time
Synchronization delay
Synchronization Delay.
7
Distributed Computing: Principles, Algorithms, and Systems
PERFORMANCE METRICS
Response time: The time interval a request waits for its CS
execution to be over after its request messages have been sent
out.
The site enters
CS Request arrives Its request the CS The site exits the CS
messages sent out
Response Time
Response Time.
PERFORMANCE METRICS
9
Distributed Computing: Principles, Algorithms, and Systems
LAMPORT’S ALGORITHM
10
Distributed Computing: Principles, Algorithms, and Systems
THE ALGORITHM
THE ALGORITHM
12
Distributed Computing: Principles, Algorithms, and Systems
THE EXAMPLE
13
Distributed Computing: Principles, Algorithms, and Systems
CORRECTNESS
Theorem: Lamport’s algorithm achieves mutual exclusion.
Proof:
Proof is by contradiction. Suppose two sites Si and Sj are executing the
CS concurrently. For this to happen conditions L1 and L2 must hold at
both the sites concurrently.
This implies that at some instant in time, say t, both Si and Sj have their
own requests at the top of their request queues and condition L1 holds at
them. Without loss of generality, assume that Si ’s request has smaller
timestamp than the request of Sj .
14
Distributed Computing: Principles, Algorithms, and Systems
CORRECTNESS
PERFORMANCE
16
17