A software approach to mutual exclusion is Lamport's bakery algorithm,so called because it is based on the practice in bakeries and other shops in which every customer receives a numbered ticket on arrival, allowing each to be served in turn.The algorithm is as: