Dekker’s Algorithm for Critical Section Problem

Dekker’s Algorithm for the Critical Section Problem

The mutual exclusion problem has different solutions. Dekker was a  Dutch mathematician who introduced a software-based solution for the mutual exclusion problem. This algorithm is commonly called Dekker’s algorithm. The Deckker’s algorithm was developed for an algorithm for mutual exclusion between two processes.

Implementation of Dekker’s Algorithm

Boolean flag[ 2]

Flag[0]  =  false;

flag[1] =  false;

Int  turn = 1;

Int PID = 0; this value is set for process P1,set this to 1and for process P2.

INT PID = 1 – PID ;

In this algorithm, the position of each process is indicated with the variables tern and flag. We can also check which process is in the critical section or not. The variable PID indicates which process is in the critical section. Similarly, we can say here that the PID2 variable represents that which process is not in its critical section.

In the above algorithm, we can see that the value of PID is set as 0 for the first process and we can and say that the first process is in its critical section.

The value of PID is set as 1 for another process that is not in its critical section.

So the value of variable PID and value of variable PID 2  are enough to tell us that a process in its critical section or not.

Advantages of Dekker’s algorithm

  1. Dekker’s algorithm helps in process synchronization.
  2. Dekker’s algorithm is the first correct solution to the critical section problem that can be proved.
  3. Dekker’s algorithm is the ideal solution for the mutual exclusion problem, especially in concurrent programming.
Latest posts by Prof. Fazal Rehman Shamil (see all)

Buy advertisement space on T4Tutorials

For more details email [email protected]