Write the RISC-V assembly code to implement the following C code as an atomic “set max” operation using the lr.d/sc.d instructions. Here, the argument shvar contains the address of a shared variable which should be replaced by x if x is greater than the value it points to:
void setmax(int* shvar, int x) {
// Begin critical section
if (x > *shvar)
*shvar = x;
// End critical section
}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here