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!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: How to get Ada to ?cross the chasm?? Date: Mon, 7 May 2018 21:05:12 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <1c73f159-eae4-4ae7-a348-03964b007197@googlegroups.com> <16406268-83df-4564-8855-9bd0fe9caac0@googlegroups.com> <87o9i2pkcr.fsf@nightsong.com> <87in88m43h.fsf@nightsong.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> NNTP-Posting-Host: kQkuQcRDy1QFvWpyB1foYw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:52070 Date: 2018-05-07T21:05:12+02:00 List-Id: On 2018-05-07 19:49, Paul Rubin wrote: > "Dmitry A. Kazakov" writes: >> The difference to GC is determinism and efficiency. You don't need to >> lock in order to decide if the object must be reclaimed. > > I don't see it. I saw the word "lock" and thought you meant a > concurrency lock, This too, because when the last reference count is zeroed it is only one task that is still aware of the object, therefore its finalization can be done without locking. > but I think you mean the notorious GC pause. Yes that > was a noticible issue in the 1980s but it's much less of one now. In > any case, something similar happens with refcounting: if you drop the > last reference to a large structure, you have to recursively traverse > the structure to decrement the refcount of everything that the structure > contains pointers to. So you still get arbitrarily long pauses. No, because I know the structures I deal with and can avoid that choosing proper design. > There are in fact realtime gc algorithms with guaranteed upper bounds on > pause length, though they aren't used that often because conventional > algorithms work well enough and have better overall performance. A > non-realtime system won't notice a millisecond pause now and then, and a > realtime system better not use refcounting either. Millisecond is very long for many applications, especially when interlocking is involved which leads to priority inversion and other nasty effects at the places you expect it least. > Refcounting is also less efficient than gc because of the need to > twiddle the refcounts all the time. That's especially expensive in > multiprocessor systems since you have to protect every refcount > operation with a lock. 1. It is three machine instructions load; increment-and-swap; branch if zero, when done in a lock-free manner. Except for very hard real-time it OK to have a second and even a third attempt. 2. In Ada controlled objects are by reference. Therefore you will not change the count when passing handles as argument to subprograms. This is as efficient as it can be. > Regarding concurrency: any concurrent system is non-deterministic by > definition. So handling non-determinisism is simply part of the deal > when you find yourself writing a concurrent program. Why? Determinism means same output/behavior for same input. Concurrency introduces non-determinism only in presence of race conditions. BTW, GC is a perfect source of race conditions. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de