[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [f-cpu] CAS in FC0



> Where does this ll/sc nomenclature come from?
>

See
http://swig.stanford.edu/pub/summaries/osstruc/nbs.html
http://www-dsg.stanford.edu/papers/non-blocking-osdi/node11.html
http://www.cs.berkeley.edu/~culler/cs258-s99/slides/lec09/sld013.htm
http://www.cs.berkeley.edu/~culler/cs258-s99/slides/lec10/sld023.htm
http://www.sgi.com/processors/r10k/manual/t5.Ver.2.0.book_43.html
www.cs.wisc.edu/~rajwar/papers/hpca00-talk.pdf (For PowerPC : lwarx and stwcx)


> [...]
> > how to implement a software CAS :
> >
> > // int CAS (int * /* pointer */ r1,int /* old value */ r2,int /* new value
*/
> > r3)
> > loadaddr 0f,r5
> > 0:
>
> loopentry r5 // ;-)
>
> > move r2,r4
> > load_tagged [r1],r2         // r2 : read value and set tag for [r1]
> > xor r2,r4,r6
> > jump.nz r6,r0,r5               // the value is not that we expect !
> > store_tagged r3,[r1],r6   // r3 : value to write into [r1] if tag still set
> > (tag is cleared afterward)
> > jump.z r6,r0,r5                 // tag was cleared before our store !
> > nxor r2,r0,r3                     // r3 != 0 if [r1] == r2 until writing r3
> > into [r1]
> > jump r0,r63                     // return to caller with result in R1
>

Forget this one, it is buggy !

> > how to implement a PUSH :
> >
> > loadaddr 0f,r5
> > move r2,r3 // our node address to push
> > 0:
> > load_tagged [r1],r2       // read top
> > store r2,[r3]                    // node->link = top
> > store_tagged r3,[r1],r4 // top = node
> > jump.nz r4,r0,r63             // return to caller if ok
> > jump r0,r5
>
> Yep. But beware! `store r2,[r3]' must not clear the tag, or else this
> function will loop forever.

r3 is the address of our node which becomes our top node
r1 is the address of a pointer where to store the address of our top node

so it should not be a problem unless you fear that our LSU entry which contains
the address of r1 is discarded by our "store [r3],r2" ?

> One more point to consider: Do we really need an extra load_tag?
> Tagging could as well be done for all loads.

It is what I said to Yann. If we have no equivalent of llp/scp, I suppose we
don't need an extra load_tag in fact.

One pdf file si speaking about a load conditional, that is a load which can
fails if locked (like our store conditional). I don't know the advantage. I
should reread this pdf.



*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/