Threads in the new ISO C Standard from 2011
Threads in the new ISO C Standard from 2011
Threads in the new ISO C Standard from 2011
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Acquire and Release a Sp<strong>in</strong> Lock<br />
# acquire<br />
loop: lwarx r6,0,r3 # load lock and reserve<br />
cmpw r4,r6 # r4 is a free lock’s value<br />
bne- loop # restart if locked.<br />
stwcx. r5,0,r3 # try to store<br />
bne loop # restart if store failed.<br />
isync # store succeeded.<br />
lwzx r7,r8,r9 # first load of shared data<br />
# release<br />
stwx r7,r8,r10 # last store of shared data<br />
lwsync # export shared data<br />
stw r4,0,r3 # unlock <strong>the</strong> lock. same r4 as above.<br />
Jonas Skeppstedt (js@cs.lth.se) Lecture 6 2013 61 / 70