Answer:
All three supports all three criteria for solving critical section problem.
Step-by-step explanation:
It’s the part of the code, where two or more cooperating processes moves atomically, and that ensures only one process is at one instance, and each of them atomically. The three criteria which need to be fulfilled are mutual exclusion, progress and bounded waiting.
The three resolutions to the critical section problematic are Petersons algorithms, test and set algorithm, and Compare and swap algorithm.
The Peterson’s algorithm provisions all the three mutual exclusion, progress and bounded waiting. It has two variables flag and turns. Turn cannot be true for both processes at a time, and hence the Mutual exclusion is supported. And with a little brain, we can find out that no two processes can be in the critical state at the same time., and if the processes that are not in the remaining state can only decide which the next process to enter the critical state is, and hence progress is also supported, and similarly each process will wait only till the turn is 1 for one time, and hence the bounded waiting is also fulfilled.
Now let’s check the test and set algorithm. In this, the memory location is checked and the memory value is being replaced with the given value. And in compare and swap, a further compare is done. One can find that in test and set, mutual exclusion is fulfilled, as not more than one process can be in a critical state at a time. The bounded waiting is not fulfilled as not all of them gets a fair chance. The same thing applies to compare and swap as well where bounded waiting is not preserved.