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!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Alejandro R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Launching background job from Ada.Real_Time.Timing_Events Date: Fri, 3 Jun 2016 12:03:53 +0200 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 3 Jun 2016 10:03:59 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="df6c13c4617621ca1de5ec657b563bf1"; logging-data="24361"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hUMBhhhYjRhamSkhkI9xp" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 In-Reply-To: Cancel-Lock: sha1:YiDbLOWPUBYQwdLfJU5JY7kEaHs= Xref: news.eternal-september.org comp.lang.ada:30574 Date: 2016-06-03T12:03:53+02:00 List-Id: On 03/06/16 09:26, Dmitry A. Kazakov wrote: > On 02/06/2016 23:25, Alejandro R. Mosteo wrote: > >> I'm sorry but I don't follow your explanation. To make things simpler, >> let's consider only the 1-to-1 case. How's this protected used without a >> blocking operation? > > If you have FIFO, a lock-free implementation is a buffer with one read > and one write index (mod buffer length). The read index never advances > beyond the write index. Reader updates the read index and looks at the > write index, and conversely the writer. Indices must have pragma Atomic, > and the buffer not cached. For example: > > http://www.dmitry-kazakov.de/ada/components.htm#10.1.1 Thanks, I was unsure if you referred to using a lock-free data type, or if it could be trivially done with the standard Ada containers with some well-known pattern I was ignorant of. I'll take a look at your library, I'm very interested in lock-free containers. A friend working on hardware architectures recently told me that a widely-used lock-free library (in the c++ world) had been proven with SPARK-like methods to be buggy. Alas, I can't remember names/dates. Thanks, Alex. > > Of course if you want to wait for a FIFO state, e.g. 'not full' or 'not > empty' you will need an event (a protected object). But you don't need > to have the FIFO a protected object. > > It is an important point not to have containers protected. Operations on > container might be quite expensive depending on the element types and > the container structure. As a rule you should not maintain containers on > the context of a protected action. E.g. if you have to do a binary > search to get an element, that is not to do in a protected action. > >>>> Any ideas? Basically, how to trigger another task (without creating it) >>>> from within a protected handler? > > By changing an entry barrier, of course. > > The task to trigger waits for a protected entry to open, it is released > after leaving the entry. >