EasyManua.ls Logo

Mips Technologies R4000 - Examples Using LL and SC

Mips Technologies R4000
754 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 11
290 MIPS R4000 Microprocessor User's Manual
Examples Using LL and SC
Figure 11-18 shows how to implement test-and-set using LL and SC
instructions.
Figure 11-18 Test-and-Set using LL and SC
Load semaphore
Unlocked?
(=0?)
Try locking
semaphore
Successful?
(r3=0?)
Unlock semaphore
Execute critical section
(Access shared data)
No
Yes
No
Yes
Loop: LL r2,(r1)
ORI r3,r2,1
BEQ r3,r2,Loop
NOP
SC r3,(r1)
BEQ r3,0,Loop
NOP
SW r2,(r1)
.
.
.
.
.

Table of Contents