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

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

1 Expert Approved Answer
Step: 1 Unlock

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

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Operating Systems Internals And Design Principles Questions!