Distributed Mutual Exclusion
Distributed Mutual Exclusion
Distributed Mutual Exclusion
Requirements/Conditions
Safety Property (Mutual Exclusion)
At any instant, only one process can execute the critical section.
Each process gets a fair chance to execute the CS. Fairness property
generally means the CS execution requests are executed in the order of
their arrival (time is determined by a logical clock) in the system.
Message complexity
Synchronization delay
After a site leaves the CS, it is the time required before the next site
enters the CS
Response time
The time interval a request waits for its CS execution to be over after its
request messages have been sent out
2
System throughput
The rate at which the system executes requests for the CS.
System throughput=1/(SD+E)
Lamport’s Algorithm
Ricart-Agrawala1 Algorithm
3
4
Lamport’s Algorithm
Basic Idea
Every site S_i keeps a queue, request queue_i , which contains mutual
exclusion requests ordered by their timestamps.
Optimization
5
Ricart-Agrawala Algorithm
Uses only two types of messages – REQUEST and REPLY.
The process that requires entry to a CS multicasts the request message to all
other processes competing for the same resource.
Each process keeps its state with respect to the CS: released, requested, or
held.
6
7
Quorum-Based Consensus – Maekawa’s Algorithm
Site obtains permission only from a subset of sites to enter CS
Guarantees safety
8
9
Ricart-Agrawala Second Algorithm
A process is allowed to enter the critical section when it gets the token.
In order to get the token it sends a request to all other processes competing
for the same resource.
it passes the token to one of the processes which are waiting for it; this
will be the first process Pj, where j is searched in order [ i+1, i+2, ..., n,
1, 2, ..., i-2, i-1] for which there is a pending request.
10
11
Suzuki-Kazami Broadcast Algorithm
If a site wants to enter the CS and it does not have the token, it broadcasts a
REQUEST message for the token to all other sites.
A site which possesses the token sends it to the requesting site upon the
receipt of its REQUEST message.
If a site receives a REQUEST message when it is executing the CS, it sends the
token only after it has completed the execution of the CS.
Two Issues
Election Algorithms
It doesn’t matter which process is elected.
What is important is that one and only one process is chosen (we call
this process the coordinator) and all processes agree on this decision.
(it doesn’t know, however, which one is still up); the process with the
highest identifier, among those which are up, is selected.
14
The Ring-based Algorithm
We assume that the processes are arranged in a logical ring
Each process knows the address of one other process, which is its
neighbor in the clockwise direction.
The algorithm elects a single coordinator, which is the process with the
highest identifier.
15
16
Distributed Deadlocks
Deadlocks is a fundamental problem in distributed systems.
A process may request resources in any order, which may not be known a
priori and a process can request resource while holding others.
Modeling Deadlocks
In addition to the standard assumptions (no shared memory, no global clock,
no failures), we make the following assumptions:
In the running state (also called active state), a process has all the
needed resources and is either executing or is ready for execution.
The state of the system can be modeled by directed graph, called a wait for
graph (WFG).
In a WFG , nodes are processes and there is a directed edge from node
P1 to mode P2 if P1 is blocked and is waiting for P2 to release some
resource.
17
A system is deadlocked if and only if there exists a directed cycle or knot in
the WFG.
Techniques
Inefficient, impractical
Deadlock Avoidance
Impractical
18
the presence of a cycle in a distributed graph structure is be
verified by propagating special messages called probes, along the
edges of the graph. The formation of cycle can be detected by a
site if it receives the matching probe sent by it previously.
Process Management
Process migration
Freeze the process on the source node and restart it at the destination
node
19
Mosix: File Access
20
Dynamic Load Balancing
Dynamic Load Balancing on Highly Parallel Computers
21
Adaptive Scheduling of Video Objects, Predictive Placement of
Video Objects
Implementation considerations
The general principle of designing DFS: know the clients have cycles to burn,
cache whenever possible, exploit usage properties, minimize system wide
change, trust the fewest possible entries and batch if possible.
Serializability
Session semantics
Copy file on open, work on local copy and copy back on close
22
Example: Sun-NFS
Supports heterogeneous systems
Architecture
Protocols
Mounting protocol
23