The first three problems in this Exercise refer to a critical section of the form lock(lk); operation

Question:

The first three problems in this Exercise refer to a critical section of the form
lock(lk);
operation
unlock(lk);
where the “operation” updates the shared variable shvar using the local (nonshared) variable x as follows:a. shvar=max(shvar,x); b. if(shvar>0) shvar=max(shvar,x); Operation

Write the MIPS assembly code for this critical section, assuming that the address of the lk variable is in $a0, the address of the shvar variable is in $a1, and the value of variable x is in $a2. Your critical section should not contain any function calls, i.e., you should include the MIPS instructions for lock(), unlock(), max(), and min() operations. Use ll/sc instructions to implement the lock() operation, and the unlock() operation is simply an ordinary store instruction.

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

Step by Step Answer:

Related Book For  answer-question

Computer Organization And Design The Hardware Software Interface

ISBN: 9780123747501

4th Revised Edition

Authors: David A. Patterson, John L. Hennessy

Question Posted: