Question: Problem C . Use compare _ and _ swap ( ) , an atomic hardware instruction to fix the race condition and solve the critical

Problem C. Use compare_and_swap(), an atomic hardware instruction to fix the race condition and solve the critical section
problem in the code given in Problem A.
MSU Denver, M&CS CS 3600: Operating Systems, Summer 2024 Dr. Weiying Zhu
a. Write a C statement to declare and initialize a shared variable lockTop, whose value is -1 when unlocked and 0 when locked
b. Re-write the push() function to call the compare_and_swap() function defined in the PPT Slide 3.18
c. Re-write the pop() function to call the compare_and_swap() function defined in the PPT Slide 3.18(Hint: other than the end of
a function, the return statement also deserves some attention.)
d. Does this solution satisfy the mutual-exclusion requirement? Does it satisfy the bounded-waiting requirement

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 Databases Questions!