From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: How to get Ada to ?cross the chasm?? Date: Wed, 9 May 2018 09:41:42 +0300 Organization: Tidorum Ltd Message-ID: References: <1c73f159-eae4-4ae7-a348-03964b007197@googlegroups.com> <87efiuope8.fsf@nightsong.com> <87lgd1heva.fsf@nightsong.com> <87zi1gz3kl.fsf@nightsong.com> <878t8x7k1j.fsf@nightsong.com> <87k1sg2qux.fsf@nightsong.com> <87h8njmk4r.fsf@nightsong.com> <87po27fbv9.fsf@nightsong.com> <87h8nhwhef.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net toyXLItdBkqw49kdxu0PaQ3P8iXKg49UK4ZtvKQJ4foTuLOIPs Cancel-Lock: sha1:+HnR+/bdTPuxZ5Cm3AgRwi3Grww= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: <87h8nhwhef.fsf@nightsong.com> Xref: reader02.eternal-september.org comp.lang.ada:52144 Date: 2018-05-09T09:41:42+03:00 List-Id: On 18-05-09 08:02 , Paul Rubin wrote: > "Dmitry A. Kazakov" writes: >> If referenced object counts are > 1 they are not going to be >> finalized. So the point stands, no locking is ever required upon >> finalization. > > I'm still perplexed by this. You have to decrement all those refcounts. > While this is happening, other threads may also be messing with them. > You need locks (at least in the form of atomic instructions which work > by hardware locks, i.e. that are much slower than normal instructions) > to prevent data races. But the atomic instructions are usually much faster than a kernel lock. > When you decrement the counts, some of them might reach zero so their > objects need freeing (and traversal). That too can be arbitrarily > complicated. Niklas mentions you can possibly do that incrementally, > but that sounds complicated As I recall, the method is that if you find that an object's reference count becomes zero, but you don't want to spend time *right now* to recursively decrement references from that object, you add the object to a global list of "garbage objects", and handle it later, as your recycling budget allows, or if no other memory is left. Not very complex, but one would have to prove that there is enough time to recycle objects "in the background" without hampering real-time behaviour, which is perhaps not so easy. But real-time GC is more complex, I believe. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .