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: Bob Duff Newsgroups: comp.lang.ada Subject: Re: Abortable Timed Action Date: Sat, 09 Jan 2016 09:41:49 -0500 Organization: A noiseless patient Spider Message-ID: <87a8oehl1u.fsf@theworld.com> References: <446ae62f-6b95-4a4f-b253-85af071b6bf6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="756e207b1d169eaf450dae70073c9509"; logging-data="6083"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+o0CqLzE9Ssr7U4Z9ZZrcQ" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:ydMER8e95+RcMFqOrAoROR4X/s8= sha1:gV0ZCT1UAKP+zW8CdqvOlDcqPVM= Xref: news.eternal-september.org comp.lang.ada:29065 Date: 2016-01-09T09:41:49-05:00 List-Id: Simon Wright writes: > GNAT certainly used to have issues in this area. Indeed, you could abort > the task and then deallocate it, and end with a memory leak (the task > control block wasn't actually freed); the cure was to wait until > 'Terminated. > > I believe that this is no longer a problem. When you call Unchecked_Deallocation on an object containing tasks that are not yet terminated, they keep running. GNAT used to have a memory leak as you say. I think it was fixed perhaps 2 years ago. So with the latest GNAT, when you call Unchecked_Deallocation, the memory is freed for tasks that are already terminated. Not-yet-terminated tasks keep running, and the memory gets freed when they terminate. It is a language design flaw that you can't block a task until some other task(s) are terminated -- other than at scope exit, which is usually way too late. You can busy wait: abort T; -- Now T is aborting itself, running finalization actions and whatnot. while not T'Terminated loop delay X; end loop; -- Here, we know that T is terminated. But X is guaranteed to be too long or too short -- most likely both. ;-) - Bob