Subject: Re: pthreads
To: Ty Sarna <tsarna@endicor.com>
From: Chris G Demetriou <Chris_G_Demetriou@lagavulin.pdl.cs.cmu.edu>
List: amiga
Date: 06/12/1995 22:30:28
> Some kind of TAS-like (or atomic mem<->reg/mem<->mem exchange or
> whatever) is needed.  However, I never noticed (until Timo pointed it
> out) that the BCLR/BSET instructions set condition codes based on the
> contenets BEFORE the operation, rather than the result like most normal
> instructions, and can thus be used as a TAS. So my answer was bogus.

Umm...  If TAS can't be used, then how could BCLR?

TAS uses a RMW memory cycle to insure atomicity.

as far as i can tell, BCLR does _NOT_ use a RMW memory cycle, and
thus is not necessarily atomic.


You should use TAS (and CAS and CAS2) for atomic operations if you
need them.  If they don't work (perhaps because the amiga doesn't
implement RMW memory cycles?)  then you're out of luck, and MUST make
a kernel call for atomic modifications.  (i can't think of any other
reason they wouldn't work, and somebody [i forget who] said that they
weren't available.) 

If BCLR _did_ use an RMW memory cycle, and it worked properly on the
amiga, then TAS would also work...  So, since TAS is documented to
use a RMW cycle (and thus be atomic), you should use it.



chris