Peterson’s solution provides a good algorithmic description of solving the critical-section problem and illustrates some of the complexities involved in designing software.
The structure of process Pi in Peterson’s solution. This solution is restricted to two processes that alternate execution between their critical sections and the remainder sections. The processes are numbered P0 and P1.