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!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!xmission!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: 4 beginner's questions on the PL Ada Date: Fri, 09 Aug 2013 20:48:58 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <87ob96ajv6.fsf@VLAN-3434.student.uu.se> <03ea570b-e45f-4694-ab9b-3413c4770379@googlegroups.com> <878v0aee8i.fsf@VLAN-3434.student.uu.se> <87ob96cxm8.fsf@VLAN-3434.student.uu.se> <92c32083-74f2-4aaa-94cc-9c9e882bfdf4@googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls7.std.com 1376095738 12699 192.74.137.71 (10 Aug 2013 00:48:58 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 10 Aug 2013 00:48:58 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:E8GJi8L7ssglRV/I8Xq4XC4tXw4= Xref: news.eternal-september.org comp.lang.ada:16764 Date: 2013-08-09T20:48:58-04:00 List-Id: This is getting a bit esoterical -- beyond the simple questions the OP was asking about how to print out the Image of a task! But anyway: Adam Beneschan writes: > But there's another factor: if you allocate a task (or a record > containing a task), using Unchecked_Deallocation (or automatic memory > reclamation) won't terminate the task. Well, there's no notion in Ada of "to terminate a task" (as in "task T1 terminates T2"). Tasks terminate themselves. Normally, when they're done. In the case of "terminate" alternatives of select statements, a task signals that it is in a ready-to-terminate state, and then gets told to go ahead and terminate itself. In the case of "abort", the task is told to terminate itself as soon as possible after it is out of any abort-deferred region. In no case does a task get terminated from outside itself. And that's as it should be. Anything else is just asking for all sorts of race conditions. So I claim it makes no sense at all for Unchecked_Deallocation of an object containing tasks to terminate those tasks. And I don't think it makes sense for U_D to abort those tasks (and then what? wait for them to terminate themselves? Or just go ahead, and hope they do so?). >...That's just the way the > language authors decided. This discussion has come up before, and > it's surprised other people that a task will still run after > Unchecked_Deallocation has been used on it, but there were reasons why > things are the way they are. I don't remember the reasons, though. I think it would make sense for U_D to await the termination of those tasks, and then free up the memory. But the actual Ada semantics are admittedly weird: U_D on an object containing running tasks doesn't free all the memory, but it expresses a hope that the memory will be freed when the tasks terminate. GNAT was recently changed so that "hope" comes true, but it's not required, and older versions of GNAT, and probably other compilers, just leak memory if you do U_D on running tasks. - Bob