Question: Using your code from Exercise 2.43 as an example, explain what happens when two processors begin to execute this critical section at the same time,
Using your code from Exercise 2.43 as an example, explain what happens when two processors begin to execute this critical section at the same time, assuming that each processor executes exactly one instruction per cycle.
Exercise 2.43
Write the MIPS 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 $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. Use ll/sc instructions to implement the lock( ) operation, and the unlock() operation is simply an ordinary store instruction.
Step by Step Solution
3.43 Rating (169 Votes )
There are 3 Steps involved in it
It is possible for one or both processors to complete ... View full answer
Get step-by-step solutions from verified subject matter experts
