Hi
I don't remember where I found this snipet of code.
LHI R1,-1 create lock (0xFFFFFFFF)
LHI R0,0 create expected lock (0)
LOOP CS R0,R1,LOCK If Lock = 0
* Store R1 into LOCK
BRZ DONE We Got The Lock
* Else, load LOCK into R0
TEST LT R0,LOCK Try Again (Simple fetch)
BRNZ TEST Still Locked
BRU LOOP No Longer Locked,
* Try CS Again
*
*
DONE CNOP 2,4 Proceed
LOCK DS A Full Word
.
In the code fragment above why is the LT (Load and Test) instruction necessary ?
What was the author trying to accomplish after Compare and Swap ?
.
.
Paul
.
.