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!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: tasking design considerations Date: Fri, 20 Jan 2017 15:11:55 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <396469b6-6efe-49e7-914b-9226637e031e@googlegroups.com> <7552bc76-fba8-4208-b855-e47140986488@googlegroups.com> NNTP-Posting-Host: vZYCW951TbFitc4GdEwQJg.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 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:33104 Date: 2017-01-20T15:11:55+01:00 List-Id: On 20/01/2017 13:32, rrr.eee.27@gmail.com wrote: > On Friday, January 20, 2017 at 9:42:36 AM UTC+1, Dmitry A. Kazakov wrote: > ... >> 2. You don't need a protected object or other locking method because a >> FIFO with a single writer and a single reader is task-safe (can be >> designed lock-free). > > I don't understand. It might be that the task reading the FIFO > starts while a callback is active adding a message to the FIFO. I think there > must be a lock to exclude reading and writing the FIFO at the same time. No. The idea is as follows. The FIFO is a ring buffer. Reader moves the out-index in the buffer. Writer does the in-index (after placing an element). Index I/O is atomic. The space to read is between out- and in-indices. The space to write in outside that. They don't overlap, thus no exclusion is needed. [ You can find an implementation here http://www.dmitry-kazakov.de/ada/components.htm#10.1 ] -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de