Maekawa’s Algorithm for Mutual Exclusion in Distributed System

14 Aug, 2019
Prerequisite – Mutual exclusion in distributed systemsMaekawa’s Algorithm is quorum based approach to ensure mutual exclusion in distributed systems. As we know, In permission based algorithms like Lamport’s Algorithm, Ricart-Agrawala Algorithm etc. a site request permission from every other site but in quorum based approach, A site does not request permission from every other site but from a subset of sites which is called quorum.
In this algorithm:
Three type of messages ( REQUEST, REPLY and RELEASE) are used.
A site send a REQUEST message to all other site in its request set or quorum to get their permission to enter critical section.
A site send a REPLY message to requesting site to give its permission to enter the critical section.
A site send a RELEASE message to all other site in its request set or quorum upon exiting the critical section.
The construction of request set or Quorum:A request set or Quorum in Maekawa’s algorithm must satisfy the following properties:
∀i ∀j : i ≠ j, 1 ≤ i, j ≤ N :: Ri ⋂ Rj ≠ ∅ i.e there is at least one common site between the request sets of any two sites.∀i : 1 ≤ i ≤ N :: Si ∊ Ri ∀i : 1 ≤ i ≤ N :: |Ri| = K Any site Si is contained in exactly K sets.N = K(K - 1) +1 and |Ri| = √N 
∀i ∀j : i ≠ j, 1 ≤ i, j ≤ N :: Ri ⋂ Rj ≠ ∅ i.e there is at least one common site between the request sets of any two sites.
∀i ∀j : i ≠ j, 1 ≤ i, j ≤ N :: Ri ⋂ Rj ≠ ∅ 
i.e there is at least one common site between the request sets of any two sites.
∀i : 1 ≤ i ≤ N :: Si ∊ Ri 
∀i : 1 ≤ i ≤ N :: Si ∊ Ri 
∀i : 1 ≤ i ≤ N :: |Ri| = K 
∀i : 1 ≤ i ≤ N :: |Ri| = K 
Any site Si is contained in exactly K sets.
N = K(K - 1) +1 and |Ri| = √N 
N = K(K - 1) +1 and |Ri| = √N 
Algorithm:
To enter Critical section:When a site Si wants to enter the critical section, it sends a request message REQUEST(i) to all other sites in the request set Ri.When a site Sj receives the request message REQUEST(i) from site Si, it returns a REPLY message to site Si if it has not sent a REPLY message to the site from the time it received the last RELEASE message. Otherwise, it queues up the request..
When a site Si wants to enter the critical section, it sends a request message REQUEST(i) to all other sites in the request set Ri.
When a site Sj receives the request message REQUEST(i) from site Si, it returns a REPLY message to site Si if it has not sent a REPLY message to the site from the time it received the last RELEASE message. Otherwise, it queues up the request.
.
To execute the critical section:A site Si can enter the critical section if it has received the REPLY message from all the site in request set Ri
A site Si can enter the critical section if it has received the REPLY message from all the site in request set Ri
To release the critical section:When a site Si exits the critical section, it sends RELEASE(i) message to all other sites in request set RiWhen a site Sj receives the RELEASE(i) message from site Si, it send REPLY message to the next site waiting in the queue and deletes that entry from the queueIn case queue is empty, site Sj update its status to show that it has not sent any REPLY message since the receipt of the last RELEASE message
When a site Si exits the critical section, it sends RELEASE(i) message to all other sites in request set Ri
When a site Sj receives the RELEASE(i) message from site Si, it send REPLY message to the next site waiting in the queue and deletes that entry from the queue
In case queue is empty, site Sj update its status to show that it has not sent any REPLY message since the receipt of the last RELEASE message
Message Complexity:Maekawa’s Algorithm requires invocation of 3√N messages per critical section execution as the size of a request set is √N. These 3√N messages involves.
√N request messages
√N reply messages
√N release messages
Drawbacks of Maekawa’s Algorithm:
This algorithm is deadlock prone because a site is exclusively locked by other sites and requests are not prioritized by their timestamp.
Performance:
Synchronization delay is equal to twice the message propagation delay time
It requires 3√n messages per critical section execution.
Distributed System
Operating Systems
Operating Systems
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.