Dekker's algorithm is the first known correct solution to the mutual exclusion problem in concurrent programming where processes only communicate via shared memory.
If the other process has not flagged intent, the critical section can be entered safely irrespective of the current turn.
One advantage of this algorithm is that it doesn't require special test-and-set (atomic read/modify/write) instructions and is therefore highly portable between languages and machine architectures.
(The use of busy waiting suggests that processes should spend a minimum amount of time inside the critical section.)
Modern operating systems provide mutual exclusion primitives that are more general and flexible than Dekker's algorithm.
However, in the absence of actual contention between the two processes, the entry and exit from critical section is extremely efficient when Dekker's algorithm is used.
This algorithm won't work on SMP machines equipped with these CPUs without the use of memory barriers.
To alleviate this problem, volatile variables should be marked as modifiable outside the scope of the currently executing context.