Maekawa's algorithm

From testwiki
Jump to navigation Jump to search

Maekawa's algorithm is an algorithm for mutual exclusion on a distributed system. The basis of this algorithm is a quorum-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

Algorithm

Requesting site:

  • A requesting site Pi sends a message request(ts,i) to all sites in its quorum set Ri.

Receiving site:

  • Upon reception of a request(ts,i) message, the receiving site Pj will:
    • If site Pj does not have an outstanding grant message (that is, a grant message that has not been released), then site Pj sends a grant(j) message to site Pi.
    • If site Pj has an outstanding grant message with a process with higher priority than the request, then site Pj sends a failed(j) message to site Pi and site Pj queues the request from site Pi.
    • If site Pj has an outstanding grant message with a process with lower priority than the request, then site Pj sends an inquire(j) message to the process which has currently been granted access to the critical section by site Pj. (That is, the site with the outstanding grant message.)
  • Upon reception of a inquire(j) message, the site Pk will:
    • Send a yield(k) message to site Pj if and only if site Pk has received a failed message from some other site or if Pk has sent a yield to some other site but have not received a new grant.
  • Upon reception of a yield(k) message, site Pj will:
    • Send a grant(j) message to the request on the top of its own request queue. Note that the requests at the top are the highest priority.
    • Place Pk into its request queue.
  • Upon reception of a release(i) message, site Pj will:
    • Delete Pi from its request queue.
    • Send a grant(j) message to the request on the top of its request queue.

Critical section:

  • Site Pi enters the critical section on receiving a grant message from all sites in Ri.
  • Upon exiting the critical section, Pi sends a release(i) message to all sites in Ri.

Quorum set (Rx):
A quorum set must abide by the following properties:

  1. ij[RiRj]
  2. i[PiRi]
  3. i[|Ri|=K]
  4. Site Pi is contained in exactly K request sets
Therefore:
  • |Ri|N1

Performance

  • Number of network messages; 3N to 6N
  • Synchronization delay: 2 message propagation delays
  • The algorithm can deadlock without protections in place.[1][2]

See also

References

Template:Reflist

  • M. Maekawa, "A √N algorithm for mutual exclusion in decentralized systems”, ACM

Transactions in Computer Systems, vol. 3., no. 2., pp. 145–159, 1985.

  • Mamoru Maekawa, Arthur E. Oldehoeft, Rodney R. Oldehoeft (1987). Operating Systems: Advanced Concept. Benjamin/Cummings Publishing Company, Inc.
  • B. Sanders (1987). The Information Structure of Distributed Mutual Exclusion Algorithms. ACM Transactions on Computer Systems, Vol. 3, No. 2, pp. 145–59.