Question

In: Computer Science

. Is the following software solution to the critical section problem correct?                      {          &nbsp

. Is the following software solution to the critical section problem correct?  

                   {

             int   lock = 0;

               ………….

               if (lock == 0) then lock = 1

                else

                        while (lock == 1) no-op;

                  enter_CS;

                         CS

                   exit_CS;

                ……….

            }

Solutions

Expert Solution

The software solution to the critical section problem is correct

int   lock = 0;

               ………….

               if (lock == 0) then lock = 1

                else

                        while (lock == 1) no-op;

                  enter_CS;

                         CS

                   exit_CS;

                ……….

            }

This is the correct solution for  critical section problem


Related Solutions

Question Four Explain Peterson’s solution for critical-section problem and show that mutual exclusion is preserved with...
Question Four Explain Peterson’s solution for critical-section problem and show that mutual exclusion is preserved with Peterson’s solution. (Assume there are only two processes P0 and P1)
A critical section problem can be solved by satisfying which of the following condition, a. Mutual...
A critical section problem can be solved by satisfying which of the following condition, a. Mutual Exclusion b. Progress c. Bounded Waiting d. All of the mentioned Give a logical reason with an example for it why and how you selected it?
End of Section Problem 13.12 Your answer is partially correct. Try again. Use the following data...
End of Section Problem 13.12 Your answer is partially correct. Try again. Use the following data to develop a regression model to predict y from x1 and x2. Comment on the output. Develop a regression model to predict y from x1 only. Compare the results of this model with those of the model using both predictors.What might you conclude by examining the output from both regression models? y x1 x2 28 12.6 134 43 11.4 126 45 11.5 143 49...
4.1) What three conditions must be satisfied in order to solve the critical section problem and...
4.1) What three conditions must be satisfied in order to solve the critical section problem and why? 4.2) Please answer each of the following questions briefly: a)   What is deadlock avoidance? (2 points) b)   What is deadlock prevention? (2 points) c)   Please discuss a strategy for deadlock avoidance (3 points) d)   Please discuss a strategy for deadlock prevention (3 points) 5. (Chapter 6) Please answer the following questions briefly (5 points each, total 10 points) 5.1) Explain the process of...
Below is an attempt to solve the producer-consumer problem. Is this a correct solution? If yes,...
Below is an attempt to solve the producer-consumer problem. Is this a correct solution? If yes, what is achieved and how? If not, what is the problem? Explain your answer in either case. (Note: Assume no syntax or compilation errors. You’re asked about the concurrency logic/correctness and the use of semaphores for this.) #define N 100                 /* number of slots in the buffer */ semaphore mutex = 1;          /* controls access to critical */ semaphore empty = N;          /* counts...
Is the following solution for the following question correct or not ? and if it's wrong...
Is the following solution for the following question correct or not ? and if it's wrong where is the mistake and how to correct it? Imagine that you own (250,000$) and you want to invest it in your dream plan. You have to consider two different alternatives. For each alternative, estimate the initial cost and annual cash flow details (operation and maintenance costs, raw material, salaries, overheads…etc.). Then compare these alternatives based on ROR criteria. Note: you don’t need to...
Operating systems Explain what the critical section problem is. Please explain this in about 1-2 paragraphs.
Operating systems Explain what the critical section problem is. Please explain this in about 1-2 paragraphs.
Which of the following statements are correct? Above the critical pressure, only the solid phase of...
Which of the following statements are correct? Above the critical pressure, only the solid phase of a pure substance can exist. Above the critical temperature, a gas may not be condensed to a liquid. At the critical point, three phases (gas, liquid, and solid) may coexist at equilibrium.
Use R.  Provide Solution and R Code within each problem. For this section use the dataset “PlantGrowth”,...
Use R.  Provide Solution and R Code within each problem. For this section use the dataset “PlantGrowth”, available in base R (you do not need to download any packages). a.Construct a 95% confidence interval for the true mean weight. b.Interpret the confidence interval in 1. in the context of the problem. c.Write down the null and alternative hypothesis to determine if the mean weight of the plants is less than 5. d.Conduct a statistical test to determine if the mean weight...
Find the critical depth, critical slope and Froude Number at section y=0.9 m in a 0.55...
Find the critical depth, critical slope and Froude Number at section y=0.9 m in a 0.55 m wide, m=1 trapezoidal channel carrying water at the rate of 0.95 m3/s. n=0.016.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT