Write the MIPS assembly code to implement the following C code as an atomic set max operation

Question:

Write the MIPS assembly code to implement the following C code as an atomic “set max” operation using the lI/sc 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

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: