GC, the simple solution
Bruno Medeiros
brunodomedeirosATgmail at SPAM.com
Sat Jun 10 09:26:28 PDT 2006
Sean Kelly wrote:
> 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.
>
>
> Sean
By "That requires synchronizing." I thought Walter meant stuff with
mutexes, etc. (i.e., non-trivial stuff), because, can't those hardware
synchronizing operations be called "atomic inc/dec" ?
--
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list