Question: 3.8 Suppose your machine has the following atomic instruction flip (lock) lock = (lock + 1 ) % 2; # flip the lock return (lock);

3.8 Suppose your machine has the following atomic instruction flip (lock) lock = (lock + 1 ) % 2; # flip the lock return (lock); # return the new value Someone suggests the following solution to the critical section problem for tweo processes: int lock= 0; #shared variable process CS[1 1 to 2] while (true) ( while (flip(lock) != 1) while (1ock l0) skip; critical section; lock 0; noncritical section; Exercises 145 (a) Explain why this solution will not work-in other words, give an execution order that results in both processes being in their critical sections at the same time (b) Suppose that the first line in the body of flip is changed to do addition module 3 rather than modulo 2. Will the solution now work for two processes? Explain your
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
