234k views
2 votes
2. Consider Dekker’s algorithm written for an arbitrary number of processes by changing the statement executed when leaving the critical section from: turn = 1 - i /* i.e., P0 sets turn to 1 and P1 sets turn to 0 */ to turn = (turn +1) % n Evaluate the algorithm when the number of concurrently executing processes is greater than two.

1 Answer

2 votes

Answer:

Algorith does not work.

Step-by-step explanation:

One of the ways to obtain the Dekker Algorithm is through a change in the declaration, that is, a declaration that can be executed at the exact moment it leaves the critical section. This way it is possible that the statement,

turn = 1-i / * P0 sets turn to 1 and P1 sets turn 0 * /

It can be changed to,

turn = (turn +1) \% n / * n = number or processes * /

The result will allow to define if it works or not, that is, if it is greater than 2 the algorithm will not be able to work.

Given this consideration we can say that,

- The dead lock does not occur, because the mutual is imposed (if a resource unit has been assigned to a process, then no other process can access that resource).

- There is the possibility of starving if the shift is established in a non-contentious process.

Directly it can be concluded that there is a possibility of starvation so the algorithm could not work, despite the fact that mutual exclusion guarantees that a dead block does not occur.

User Rowno
by
5.7k points