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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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!.POSTED!not-for-mail From: =?UTF-8?Q?Bj=c3=b6rn_Lundin?= Newsgroups: comp.lang.ada Subject: Re: tasking design considerations Date: Fri, 20 Jan 2017 09:29:50 +0100 Organization: A noiseless patient Spider Message-ID: References: <396469b6-6efe-49e7-914b-9226637e031e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 20 Jan 2017 08:28:08 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="c551ce659c8df608c2aa63ab417abd7b"; logging-data="12794"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+sfB/svCVVfX4Xjb0G7GBt" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 In-Reply-To: <396469b6-6efe-49e7-914b-9226637e031e@googlegroups.com> Cancel-Lock: sha1:f+PkCRf+pYmwQCdg0IWEhoJPUw4= Xref: news.eternal-september.org comp.lang.ada:33101 Date: 2017-01-20T09:29:50+01:00 List-Id: On 2017-01-20 09:07, rrr.eee.27@gmail.com wrote: > I want now create a protected object stack. The callbacks from channel A fill the stack on the top. > A cyclic task with a cycle time T reads and removes all collected messages from the bottom of the stack. Instead of polling the stack, you could have a an entry with a barrier in the PO that the task hangs upon. the PO would then have procedure Put_On_Stack(Msg) entry Get_From_Stack(Msg) when Cnt > 0; function Count return Natural; private Cnt : Natural := 0; Put_On_Stack increases Cnt Get_On_Stack decreases Cnt The task could then do loop Get_From_Stack(msg); -- <-- entry with barrier exit when msg = exit_message; process(msg) end loop; The barrier/guard on the entry would be 'stack is not empty' and to bring the task down at exit of process, define an exit message and put that in the bottom of the stack for fast exit, or on the top if processing the whole stack is more important than a fast exit -- Björn