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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started