Lamport’s Bakery Algorithm

What Does Lamport’s Bakery Algorithm Mean?

Lamport’s bakery algorithm is a computing algorithm that ensures efficient use of shared resources in a multithreaded environment. This algorithm was conceived by Leslie Lamport and was inspired by the first-come-first-served, or first-in-first-out (FIFO), operational methodology of a bakery. Lamport’s bakery algorithm is a mutual exclusion algorithm that restricts two or more processes from accessing a resource simultaneously.


Techopedia Explains Lamport’s Bakery Algorithm

The operational principles behind Lamport’s bakery algorithm are very simple. All process threads must take a number and wait their turn to use a shared computing resource or to enter their critical section. The number can be any of the global variables, and processes with the lowest number will be processed first. If there is a tie or similar number shared by both processes, it is managed through their process ID. If a process terminates before its turn, it has to start over again in the process queue.


Related Terms

Margaret Rouse

Margaret is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages.