GC, the simple solution

Sean Kelly sean at f4.ca
Wed Jun 7 12:19:53 PDT 2006

Bruno Medeiros wrote:
> 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." ?

These are synchronizing operations.


More information about the Digitalmars-d mailing list