Computer Science 330
Operating Systems
Fall 2025, Siena University
Agenda
We looked at Peterson's Algorithm in class as a software solution to the critical section problem for two processes. Another solution is due to Dekker:
int turn=0; boolean flag[2]; flag[0]=false; flag[1]=false;
while (1) { flag[i]=true; while (flag[j]) { if (turn != i) { flag[i]=false; while (turn != i); flag[i]=true; } } /* critical section */ turn=j; flag[i]=false; /* non-critical section */ }
Terminology
Examples