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: border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!border2.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fx19.iad.POSTED!not-for-mail From: Brad Moore User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Termination of tasks waiting on a protected queue References: <91780287-64c4-48e4-8cb1-89909b5d59f9@googlegroups.com> In-Reply-To: <91780287-64c4-48e4-8cb1-89909b5d59f9@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 68.145.219.148 X-Complaints-To: internet.abuse@sjrb.ca X-Trace: 1401239091 68.145.219.148 (Wed, 28 May 2014 01:04:51 UTC) NNTP-Posting-Date: Wed, 28 May 2014 01:04:51 UTC Date: Tue, 27 May 2014 19:04:50 -0600 X-Received-Bytes: 3008 X-Received-Body-CRC: 3637145835 X-Original-Bytes: 3337 Xref: number.nntp.dca.giganews.com comp.lang.ada:186675 Date: 2014-05-27T19:04:50-06:00 List-Id: On 14-05-27 05:08 AM, Alejandro R. Mosteo wrote: > On Monday, May 19, 2014 1:05:59 AM UTC+2, Brad Moore wrote: >> On 14-05-18 01:32 AM, Natasha Kerensikova wrote: >> >>> The problem is, how to terminate cleanly the worker tasks in a >> >>> non-Ravenscar environment when the main application is completed? >> >>> >> >>> From my understanding of ARM 9.3, I need a terminate alternative in the >> >>> worker tasks. But those can only exist in selective accepts, so I have >> >>> to turn things around and make the task wait for one of its entries to >> >>> be called, rather than wait for an external protected entry. >> >>> >> >>> But then, how can a worker task entry be used to solve my problem? A >> >>> protected operation cannot call a task entry, because it's potentially >> >>> blocking. The job generator cannot call the entry directly, because it >> >>> would block when the task is not ready, so I still need a queue between >> >>> the generator and the worker task. >> >> >> >> A protected entry can however requeue to a task entry. >> >> >> I did not want the programmer to have to call some protected subprogram >> >> to trigger the task pool to terminate. > > Could an atomic boolean be used to avoid a protected object? Given that after it being set it wouldn't be unset, and there's no race condition, I wonder. > The problem is not the protected subprogram. It is having to force the programmer to explicitly specify somewhere in the code a trigger to initiate the destruction of the task pool, whether via a protected object or setting an atomic boolean, or some other means. Setting the trigger before the main task exits for instance, is error prone because there may be other tasks executing that might still want to use the task pool. Using the mechanism I suggested means the task pool does not get destroyed until all tasks have completed, since the main task wont exit until all other tasks have either completed or are waiting on a select statement with a Terminate alternative.