Definition
Dekker’s algorithm is one of the first software-only algorithms for mutual exclusion between two threads.
Core idea
- Each thread raises its own
flagbefore entering the critical section. - If both threads want to enter, a shared
turnvariable breaks the tie. - When leaving, a thread gives priority to the other thread and lowers its flag.