Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(a) Write the assembly code to implement an atomic compare&swap using load-linked and store-conditional. Compare&swap (r1,r2,x) works as follows: Typically r1 is O (for unlocked)
(a) Write the assembly code to implement an atomic compare&swap using load-linked and store-conditional. Compare&swap (r1,r2,x) works as follows: Typically r1 is O (for unlocked) and r2 is 1 (for locked) 1. If (r1 = MEMIx)) then { r2 = MEM[x] MEM[x] = r2 FYI: atomic swap is implemented in some systems (e.g., IBM POWER and Intel x86). (b) Test-and-set incurs high traffic while spin waiting. What happens to compare&swap? (a) Write the assembly code to implement an atomic compare&swap using load-linked and store-conditional. Compare&swap (r1,r2,x) works as follows: Typically r1 is O (for unlocked) and r2 is 1 (for locked) 1. If (r1 = MEMIx)) then { r2 = MEM[x] MEM[x] = r2 FYI: atomic swap is implemented in some systems (e.g., IBM POWER and Intel x86). (b) Test-and-set incurs high traffic while spin waiting. What happens to compare&swap
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