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: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Advice, tasking and hardware Date: Fri, 27 May 2016 21:13:12 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <25c43463-47ca-4021-82ee-299e6a075faa@googlegroups.com> <2c0dfaf8-9344-4b9c-87b4-12de687687ce@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Sat, 28 May 2016 04:09:34 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="48b46be33beed75863f69afa437f956b"; logging-data="15489"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iZ6roLEO/ODC3bkU2q23KTpjuZHGsyxs=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 In-Reply-To: <2c0dfaf8-9344-4b9c-87b4-12de687687ce@googlegroups.com> Cancel-Lock: sha1:CqJ67ULMHCDVr4k64ZcbiWSzaa4= X-Enigmail-Draft-Status: N1110 Xref: news.eternal-september.org comp.lang.ada:30501 Date: 2016-05-27T21:13:12-07:00 List-Id: On 05/27/2016 05:25 PM, rieachus@comcast.net wrote: > > package Shutdown is > task Suspend is > entry Stop; > entry Wait; > end Suspend; > end Shutdown; > ... > package body Shutdown is > begin > task body Suspend is > begin > accept Stop; > loop > select > accept Wait; > or > accept Stop; -- in case of multiple calls to Stop. > or > terminate; > end select; > end loop; > end Shutdown; Is there any reason for this to be a task? I've always used a protected object: package Shutdown is protected Control is procedure Time_To_Die; -- Tell the system to shut down function Time_To_Die return Boolean; -- Returns True if the system is shutting down entry Wait; -- Blocks until the system is shutting down private -- Control Shutting_Down : Boolean := False; end Control; end Shutdown; Procedure Time_To_Die sets Shutting_Down to True, function Time_To_Die returns Shutting_Down, and Wait is null and has the barrier "when Shutting_Down". Procedure Time_To_Die and Wait work the same as Stop and Wait. The function is useful for sporadic tasks that block on an entry waiting for something to do. -- Jeff Carter "I'm a kike, a yid, a heebie, a hook nose! I'm Kosher, Mum! I'm a Red Sea pedestrian, and proud of it!" Monty Python's Life of Brian 77