Question: Consider a computer that does not have a TEST AND SET LOCK instruction but does have an instruction to swap the contents of a register
Consider a computer that does not have a TEST AND SET LOCK instruction but does have an instruction to swap the contents of a register and a memory word in a single indivisible action. Can that be used to write a routine enter_region such as the one found in Fig. 2-12?
enter_region: TSL REGISTER, LOCK CMP REGISTER,#0 JNE ENTER REGION RET leave region: | copy LOCK to register and set LOCK to 1 was LOCK zero? | if it was non zero, LOCK was set, so loop | return to caller; critical region entered MOVE LOCK, #0 RET | store a 0 in LOCK I return to caller Figure 2-12. Entering and leaving a critical region using the TSL instruction.
Step by Step Solution
3.41 Rating (157 Votes )
There are 3 Steps involved in it
Yes it is possible to write a routine enterregion such as the one found in Figure 212 on a computer that does not have a TEST AND SET LOCK instruction ... View full answer
Get step-by-step solutions from verified subject matter experts
