https://github.com/keyan/lamport-bakery-algorithm
Mutual exclusion locking without atomic CPU operations
https://github.com/keyan/lamport-bakery-algorithm
Last synced: 8 months ago
JSON representation
Mutual exclusion locking without atomic CPU operations
- Host: GitHub
- URL: https://github.com/keyan/lamport-bakery-algorithm
- Owner: keyan
- Created: 2018-01-20T06:31:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-20T06:32:20.000Z (over 8 years ago)
- Last Synced: 2025-02-09T00:42:44.830Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Lamport's Bakery Algorithm
An implementation of Lamport's Bakery Algorithm. Originally published in 1974:
"A New Solution of Dijkstra's Concurrent Programming Problem"
Communications of the ACM - Aug 1974 17:8
The unique and interesting aspect of this algorithm is that it provides FIFO mutual exclusion without the use of any atomic hardware operations. At the time of publication this had never been done before. While the practical benefit of a software approach is perhaps limited, it is a very clever and interesting algorithm.
The original paper is very accessible (especially so for a Lamport paper) and the proof of correctness is quite intuitive and helps with understanding _why_ the algorithm works. It can be initially confusing why the unsafe read of `choosing[j]` in the lock loop doesn't interfere with the correctness of the algorithm, but indeed it doesn't matter what this read returns, the subsequent operations will still be done correctly.
Original paper:
http://lamport.azurewebsites.net/pubs/bakery.pdf