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!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.ada Subject: Re: How to get Ada to ?cross the chasm?? Date: Mon, 07 May 2018 13:29:30 -0700 Organization: A noiseless patient Spider Message-ID: <87po27fbv9.fsf@nightsong.com> References: <1c73f159-eae4-4ae7-a348-03964b007197@googlegroups.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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="8e10b317856a6344fb35132252789110"; logging-data="6652"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yhjjtgCDLxKT9RkTvc9kM" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cancel-Lock: sha1:1mpkacKuGpilylPY1vJXfHUgHXk= sha1:/d70ZbBMsDnYyKPMtDVSOxmgXoo= Xref: reader02.eternal-september.org comp.lang.ada:52071 Date: 2018-05-07T13:29:30-07:00 List-Id: "Dmitry A. Kazakov" writes: > 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. The big object contains many references to other objects, and those objects' refcounts don't necessarily become zero when the big object's last reference goes away. They all have to be updated while other tasks might be simultaneously updating them. >> So you still get arbitrarily long pauses. > No, because I know the structures I deal with and can avoid that > choosing proper design. In other words you are manually managing memory, which is what refcounting is supposed to get you out of. If you spent even one minute figuring out that proper design, that's a minute that a GC-using programmer could have spent doing something productive. > Millisecond is very long for many applications, In such a system you better not use a refcount scheme either, without a WCET analysis. I'd add as well: most refcount systems I know of don't move objects around in memory, so you get memory fragmentation and high cache miss rates. GC systems typically compact the heap when the GC runs, with heap sizes chosen so that "minor" collections put the most recently allocated (and in practice most frequently used) part of the heap into the processor's L2 cache. > 1. It is three machine instructions load; increment-and-swap; branch > if zero, when done in a lock-free manner. What processor do you mean, that has an increment-and-swap instruction? I don't think the x86 has this. You would use LOCK CMPXCHG which is quite slow. > Why? Determinism means same output/behavior for same > input. Concurrency introduces non-determinism only in presence of race > conditions. Concurrency means that the program responds to input from multiple independent sources whose timing is outside of the program's control. That's non-deterministic by definition. "Same output/behavior for same input" doesn't mean much because you can't expect to ever get the same input. For a concurrent program to be correct, it must correctly handle every possible interleaving of input events. There is no deterministic timing in anything nontrivial either, again because of caches in the memory system and the i/o peripherals. Even without caching there is no determinism. In the old days of rotating hard disks, the latency of a read operation would vary slightly because of the motion of air molecules inside the drive, i.e. it was affected by thermal noise. This was sometimes used a source of physical random data to seed random number generators in software systems. So when multiprocessors and critical timing are involved, determinism in real-world programming simply doesn't exist. Any concurrency scheme or WCET analysis must take this into account.