2. Syllabus:
Introduction, Classification of Mutual Exclusion
Algorithms, Preliminaries, A simple solution to
Distributed Mutual Exclusion, Non-Token-Based
Algorithms, Lamport’s Algorithm, The Ricart-
Agrawala Algorithm, Token-Based Algorithms, Suzuki-
Kasami’s Broadcast Algorithms.
Dr.Somnath Thigale
3. Introduction
Mutual exclusion is a concurrency control property which is
introduced to prevent race conditions. It is the requirement
that a process can not enter its critical section while another
concurrent process is currently present or executing in its
critical section i.e only one process is allowed to execute the
critical section at any given instance of time.
Dr.Somnath Thigale
4. Classification of Mutual
Exclusion Algorithms
The algorithms are grouped into 2 classes:
1. Token Based Algorithm:
A unique token is shared among all the sites.
If a site possesses the unique token, it is allowed to enter its
critical section
This approach uses sequence number to order requests for the
critical section.
Each requests for critical section contains a sequence number.
This sequence number is used to distinguish old and current
requests.
This approach insures Mutual exclusion as the token is unique
Example: Suzuki-Kasami’s Broadcast Algorithm
Dr.Somnath Thigale
5. 2. Non-token based approach:
A site communicates with other sites in order to determine which
sites should execute critical section next. This requires exchange of
two or more successive round of messages among sites.
This approach use timestamps instead of sequence number to
order requests for the critical section.
When ever a site make request for critical section, it gets a
timestamp. Timestamp is also used to resolve any conflict
between critical section requests.
All algorithm which follows non-token based approach maintains a
logical clock. Logical clocks get updated according to Lamport’s
scheme
Example: Lamport's algorithm, Ricart–Agrawala algorithm
Dr.Somnath Thigale
6. 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.
Dr.Somnath Thigale
7. Requirements of mutual exclusion algorithm:
1. Freedom from deadlock- 2 or more sites should not
endlessly wait for message that will never arrive.
2. Freedom from starvation: a site should not be forced to wait
indefinitely to execute CS while other sites are repeatedly
executing CS.
3. Fairness: request must be executed in the order they are
made
4. Fault tolerance: if in the wake of a failure, it can recognize
itself so that it continues to function without any
(prolonged) disruption.
Dr.Somnath Thigale
8. A simple solution to Distributed
Mutual Exclusion
A control site is assigned the task of granting
permission for the CS execution.
To request the CS, a site sends a REQUEST message
to the control site.
The control site queues up the requests for the CS
and grants them permission, one by one.
This requires only 3 messages per CS execution.
If the synchronization delay is reduced to T, the
system throughput is almost doubled to 1/(T+E).
Dr.Somnath Thigale
9. Non-Token-Based Algorithms
In this a site communicates with a set of
other sites to arbitrate who should execute
the CS next.
For a site Si, request set Ri contains ids for
all those sites from which site Si must
acquire permission before entering the CS.
These algorithm use timestamp to order
requests for the CS and to resolve conflicts
between simultaneous requests for the CS.
Dr.Somnath Thigale