shared: bool flag[] = { false, false }; // Do I want to be in the C.S. int turn = 0; // Whose turn is it not to be polite Process 0 | Process 1 ---------------------------+-------------------------- flag[0] = true; | flag[1] = true; while (flag[1]) | while (flag[0]) { if (turn == 0) | { if (turn == 1) pause(); | pause(); else | else { flag[0] = false; | { flag[1] = false; pause(); | pause(); flag[0] = true; } } | flag[1] = true; } } C.S. | C.S. turn = 1; | turn = 0; flag[0] = false; | flag[1] = false; | (Dekker's algorithm)