Question: Write the LEGv8 assembly code to implement the following C code: lock(lk); shvar=max(shvar,x); unlock(lk); Assume that the address of the lk variable is in X0,
Write the LEGv8 assembly code to implement the following C code:
lock(lk); shvar=max(shvar,x); unlock(lk);
Assume that the address of the lk variable is in X0, the address of the shvar variable is in X1, and the value of variable x is in X2. Your critical section should not contain any function calls use LDXR/STXR to perform an atomic update of the shvar variable directly, without using lock() and unlock(). Note that in this exercise there is no variable lk.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
