Under the Hood of the Bakery Algorithm: Mutual Exclusion as a Matter of Priority

  • Yoram Moses
  • Katia Patkin
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9439)


A new approach to the study and analysis of Mutual Exclusion (ME) algorithms is presented, based on identifying the priority relation that the ME algorithm constructs. It is argued that by analyzing how a process detects that it has priority over all other processes, ME algorithms can be better understood and improved. The approach is illustrated by applying it to Lamport’s celebrated Bakery algorithm in the safe register SWMR model. By analyzing how Bakery established and detects priority, cases in which the Bakery algorithm causes processes to block unnecessarily are identified. Namely, a process that already knows that it has priority over another process is made to perform reads and wait on registers of the other process. An optimized version of the Bakery algorithm, called Boulangerie, is proposed, and is shown to be free of any unnecessary blocking. A second contribution of the approach is obtaining a clear explanation for how the Bakery algorithm uses reads from safe registers to detect that a process has priority. Our analysis provides more insight into the workings of the Bakery algorithm than is obtained by other proofs of its correctness.


mutual exclusion Bakery algorithm safe registers Boulangerie algorithm 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Abraham, U.: Logical classification of distributed algorithms (Bakery Algorithms as an example). Theor. Comput. Sci. 412(25), 2724–2745 (2011)MathSciNetCrossRefMATHGoogle Scholar
  2. 2.
    Anderson, J.H.: Lamport on mutual exclusion: 27 years of planting seeds. In: Proceedings of the 20th ACM PODC Conference, pp. 3–12 (2001)Google Scholar
  3. 3.
    Attiya, H., Welch, J.: Distributed computing: fundamentals, simulations, and advanced topics, vol. 19 (2004)Google Scholar
  4. 4.
    Chaudhuri, K., Doligez, D., Lamport, L., Merz, S.: Verifying safety properties with the TLA+ proof system. In: Giesl, J., Hähnle, R. (eds.) IJCAR 2010. LNCS, vol. 6173, pp. 142–148. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  5. 5.
    Dijkstra, E.W.: Solution of a problem in concurrent programming control. Commun. ACM 8(9), 569 (1965)CrossRefGoogle Scholar
  6. 6.
    Fagin, R., Halpern, J.Y., Moses, Y., Vardi, M.Y.: Reasoning about Knowledge (2003)Google Scholar
  7. 7.
    Halpern, J.Y., Moses, Y.: Knowledge and common knowledge in a distributed environment. Journal of the ACM 37(3), 549–587 (1990)MathSciNetCrossRefMATHGoogle Scholar
  8. 8.
    Hesselink, W.H.: Mechanical verification of Lamport’s Bakery Algorithm. Science of Computer Programming 78(9), 1622 (2013)CrossRefGoogle Scholar
  9. 9.
    Lamport, L.: A new solution of Dijkstra’s concurrent programming problem. Commun. ACM 17(8), 453–455 (1974)MathSciNetCrossRefMATHGoogle Scholar
  10. 10.
    Lamport, L.: A new approach to proving the correctness of multiprocess programs. ACM Trans. Program. Lang. Syst. 1(1), 84–97 (1979)CrossRefMATHGoogle Scholar
  11. 11.
    Lamport, L.: What it means for a concurrent program to satisfy a specification: Why no one has specified priority. In: Proceedings of the 12th ACM POPL, pp. 78–83 (1985)Google Scholar
  12. 12.
    Lamport, L.: On Interprocess Communication. Part I: Basic Formalism. Distributed Computing 1(2), 77–85 (1986)MATHGoogle Scholar
  13. 13.
    Lamport, L.: A fast mutual exclusion algorithm. ACM Trans. Comput. Syst. 5(1), 1–11 (1987)CrossRefGoogle Scholar
  14. 14.
    Lamport, L.: A TLA+ mechanical proof of the Boulangerie Algorithm (2015). http://research.microsoft.com/en-us/um/people/lamport/tla/boulangerie.html
  15. 15.
  16. 16.
    Lynch, N.A.: Distributed Algorithms (1996)Google Scholar
  17. 17.
    Raynal, M., Beeson, D.: Algorithms for Mutual Exclusion (1986)Google Scholar
  18. 18.
    Rosenzweig, D., Börger, E., Gurevich, Y.: The bakery algorithm: yet another specification and verification. In: Börger, E. (ed.) Specification and Validation Methods, pp. 231–243 (1995)Google Scholar
  19. 19.
    Sedletsky, E., Pnueli, A., Ben-Ari, M.: Formal verification of the ricart-agrawala algorithm. In: Kapoor, S., Prasad, S. (eds.) FST TCS 2000. LNCS, vol. 1974, pp. 325–335. Springer, Heidelberg (2000)CrossRefGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2015

Authors and Affiliations

  • Yoram Moses
    • 1
  • Katia Patkin
    • 1
  1. 1.Technion - Israel Institute of TechnologyHaifaIsrael

Personalised recommendations