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!feeder.eternal-september.org!news.uzoreto.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: How to terminate all running tasks? Date: Wed, 10 Jun 2020 15:29:19 +0300 Organization: Tidorum Ltd Message-ID: References: <7c14755d-f5f0-4000-bde1-d34423cf43abo@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net H1YClQ+Ynij2g4I0Amxi2wnJxKXfkedVJXJTfsjoRsWBic+vD+ Cancel-Lock: sha1:wNLJug2AJEiiF8eaBacgWWnnXtE= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 In-Reply-To: Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:59033 Date: 2020-06-10T15:29:19+03:00 List-Id: On 2020-06-10 15:12, Niklas Holsti wrote: > and in the main subprogram, instead of the null statement and the > exception handler: > >    Ada.Synchronous_Task_Control.Suspend_Until_True (solution_found); >    abort p6p; >    abort p6m; Just an addendum: to make sure that the main subprogram runs, and is not starved by a child task that is still searching for a solution, you may want to make the priorities of the child tasks lower than the priority of the main subprogram (the environment task). And a further note: generally one should avoid aborting tasks, as that easily leads to messy race conditions. Better to have the tasks terminate by themselves. For example, each of the search tasks could now and then call Ada.Synchronous_Task_Control.Current_State (solution_found) and terminate itself (exit the loop) if the result is True. -- Niklas Holsti niklas holsti tidorum fi . @ .