Question: Consider the following solutions to the critical section problem with two processes i and j. The given code is for process i; the code of
Consider the following solutions to the critical section problem with two processes i and j. The given code is for process i; the code of process j is symmetrical.
For each of the following properties, state whether it is satisfied or not (YES or NO). In case your answer is YES, give an explanation in less than 100 words.
In case the answer is NO, give an appropriate example that proves your answer, in less than 100 words. These are the properties:
P1) (Mutual Ex) At any moment, at most one thread is in its Critical Sections
P2) (Liveness) If one or more threads want to go into CS< then within a finite time (wft) some thread will be in CS
P3) For all threads i: j, if I wants to go into CS then within a finite time, i will go into CS Code: Global Code/Vars: flag[i] = false;
flag[j] = false;
turn = i;
-----
enter_cs(i) flag[i] = true;
turn=i;
while(turn==i OR flag[j]);
-----
exit_cs(i)
flag[i]=false;
----
The code is symmetrical for the other process. Does this mean its the same just its for process j? Can anyone explain how you solve this problem? I'm confused. Not just a solution, explain how you solve it so I can do others on my own. Thanks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
