GC, the simple solution

Bruno Medeiros brunodomedeirosATgmail at SPAM.com
Wed Jun 7 12:03:15 PDT 2006

Walter Bright wrote:
>> Only if the reference is stored,
>> the ref counter has to be incremented. This is only possible if this is
>> done by the compiler. No smart pointer can do this :)
>>> 3) in a multithreaded app, the incs and decs must be synchronized
>> Isn't a atomic inc/dec enough?
> That requires synchronizing.

Are you sure? It says in 
http://www.iecc.com/gclist/GC-algorithms.html#Reference%20counting that:
"In a multi-threaded system, if threads are preemptively scheduled, 
reference counting requires additional care to ensure that the updates 
to reference counts are atomic. This is straightforward using hardware 
primitives such as fetch-and-add, compare-and-swap, or 
load-linked/store-conditional, but it is definitely necessary to pay 
attention to this detail." ?

Bruno Medeiros - CS/E student

More information about the Digitalmars-d mailing list