Explain Peterson's solution to the critical-section problem. What assumptions does it rely on?
Last updated
A software-only two-process lock: each process sets
flag[i] = true(intent to enter), then yields withturn = j, and busy-waits while the other's flag is set and it's the other's turn.It satisfies mutual exclusion, progress, and bounded waiting (at most one bypass).
It assumes exactly two processes, atomic loads/stores, and sequential consistency. Modern out-of-order CPUs and compilers break the last one without memory barriers.
- https://en.wikipedia.org/wiki/Peterson%27s_algorithm
- https://www.tutorialspoint.com/article/what-is-peterson-s-solution
- https://parashar--manas.medium.com/understanding-operating-system-critical-section-problem-solution-part-35-petersons-algorithm-a7ab17181d4e
- https://www.tutorialspoint.com/article/peterson-s-problem
- https://dev.to/harshm03/critical-section-problem-process-synchronization-310d
- https://blog.jyotiprakash.org/petersons-solution-to-the-critical-section-problem
- https://www.geeksforgeeks.org/operating-systems/n-process-peterson-algorithm/
- https://medium.com/@saqlain9696382/petersons-solution-explained-with-a-super-easy-example-synchronization-operating-systems-e752d792823f