Maekawa's algorithm is an algorithm for
mutual exclusion
In computer science, mutual exclusion is a property of concurrency control, which is instituted for the purpose of preventing race conditions. It is the requirement that one thread of execution never enters a critical section while a concurrent ...
on a
distributed system
A distributed system is a system whose components are located on different networked computers, which communicate and coordinate their actions by passing messages to one another from any system. Distributed computing is a field of computer sci ...
. The basis of this algorithm is a
quorum
A quorum is the minimum number of members of a deliberative assembly (a body that uses parliamentary procedure, such as a legislature) necessary to conduct the business of that group. According to '' Robert's Rules of Order Newly Revised'', the ...
-like approach where any one site needs only to seek permissions from a subset of other sites.
Algorithm
Terminology
* A ''site'' is any computing device which runs the Maekawa's algorithm
* For any one request of entering the critical section:
** The ''requesting site'' is the site which is requesting to enter the critical section.
** The ''receiving site'' is every other site which is receiving the request from the requesting site.
* ''ts'' refers to the local time stamp of the system according to its
logical clock
A logical clock is a mechanism for capturing chronological and causal relationships in a distributed system. Often, distributed systems may have no physically synchronous global clock. In many applications (such as distributed GNU make), if two p ...
Algorithm
Requesting site:
* A requesting site
sends a message
to all sites in its quorum set
.
Receiving site:
* Upon reception of a
message, the receiving site
will:
** If site
does not have an outstanding
message (that is, a
message that has not been released), then site
sends a
message to site
.
** If site
has an outstanding
message with a process with higher priority than the request, then site
sends a
message to site
and site
queues the request from site
.
** If site
has an outstanding
message with a process with lower priority than the request, then site
sends an
message to the process which has currently been granted access to the critical section by site
. (That is, the site with the outstanding
message.)
* Upon reception of a
message, the site
will:
** Send a
message to site
if and only if site
has received a
message from some other site or if
has sent a yield to some other site but have not received a new
.
* Upon reception of a
message, site
will:
** Send a
message to the request on the top of its own request queue. Note that the requests at the top are the highest priority.
** Place
into its request queue.
* Upon reception of a
message, site
will:
** Delete
from its request queue.
** Send a
message to the request on the top of its request queue.
Critical section:
* Site
enters the critical section on receiving a
message from all sites in
.
* Upon exiting the critical section,
sends a
message to all sites in
.
Quorum set (
):
A quorum set must abide by the following properties:
#