Question: 1.Fetch And Add (FAA), atomically increments a variable and returns the old value of the variable. FAA (var, increment) adds increment to the variable var
1.Fetch And Add (FAA), atomically increments a variable and returns the old value of the variable. FAA (var, increment) adds increment to the variable var and returns the initial value of var. We plan to use this for mutual exclusion. (10pts) shared int S; // each process executes while (TRUE) { enter_section(); // Here is the critical section ... exit_section(); // This is the remainder section ... } // enter_section() returns when it is safe to enter the critical section void enter_section(){ while (FAA(S, -1) < 1) { FAA (S, 1); } } a) (3 points) What should be the initial value of S for this code to work? b) (7 points) Write the code for exit_section()?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
