Explanation
- **Dekker’s Algorithm** is a mutual exclusion algorithm used to ensure that only one process accesses the critical section at a time. It is one of the first algorithms to solve the mutual exclusion problem in concurrent programming.
-
-
Steps
- Two processes:
P0andP1share two flags and a turn variable. - Process 0: Sets its flag to
True, then waits for process 1’s flag to beFalseand for the turn variable to allow it. - Process 1: Does the same for process 0.
- Both processes: Wait for each other in a loop until both flags and the turn condition are met.
- Two processes:
-
Time Complexity
- Time complexity: O(1) for entering and exiting the critical section.