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...


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


}


}



Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here