Re: shared_ptr from dinkumware ... comments??
Chris Thomasson wrote:
[...]
Reference counting requires cas, which isn't present in Sparc
You can implement shared_ptr, or full-blown atomically
thread-safe counted pointers with swap and fetch-and-add...
Like I did here:
http://appcore.home.comcast.net/vzoom/refcount/
I found two errors in your assembler code in the first five
minutes looking at it. You are basically using a spin lock,
which can deadlock if real time thread scheduling is in effect.
And even in the spin lock, you forgot a lock prefix on the exch
instruction, which means that it isn't atomic, and two threads
can enter the critical section at the same time.
If you do find a lock-free implementation of full reference
counted pointers which only needs an atomic swap, you would do
well to publish it in a refereed journal, like the CACM, because
it is generally considered impossible.
For the rest, the moderator is correct: this is no longer on
topic, and further discussion should be
comp.programming.threads. The problem isn't C++, it's a
question of the hardware support needed for certain operations.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]