Question: 3. Consider two processes po, pland a shared variable int buffer [2] which takes only two 6 values 0 or 1. If value of

3. Consider two processes po, pland a shared variable int buffer [2]

 

3. Consider two processes po, pland a shared variable int buffer [2] which takes only two 6 values 0 or 1. If value of buffer [0] is 1 then p0 will enter into the critical section and p1 [1] is 1 then pl will enter into the critical section. Initially both values of buffer variable is zero. For the above scenario I have proposed a "solution to the critical- section problem. Determine its correctness. If it is incorrect then show an example that violates mutual exclusion and write the correct statement that can solve the problem. int turn=0; int flag[2]={0}: Process i{ } while (true){ } j = other process's ID; flag[i] = 1; while (flag[i]): turn = i: CRITICAL_SECTION flag[i] = 0;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!