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!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: 4 beginner's questions on the PL Ada Date: Mon, 12 Aug 2013 14:47:11 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <87ob96ajv6.fsf@VLAN-3434.student.uu.se> <03ea570b-e45f-4694-ab9b-3413c4770379@googlegroups.com> <878v0aee8i.fsf@VLAN-3434.student.uu.se> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1376336832 20660 69.95.181.76 (12 Aug 2013 19:47:12 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Mon, 12 Aug 2013 19:47:12 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:16832 Date: 2013-08-12T14:47:11-05:00 List-Id: "Jeffrey Carter" wrote in message news:ku3opa$svn$3@dont-email.me... > On 08/09/2013 02:38 PM, Emanuel Berg wrote: >> >> Yes! This works great: >> >> with Ada.Task_Identification; >> use Ada.Task_Identification; >> >> Task_Name : constant String := Image(Current_Task); >> >> It produces output like >> >> add_one_081838Dt >> >> if the task is referred to as Add_One in the code. > > Not necessarily. First, this is only available in compilers that choose to > implement the optional Annex C, Systems Programming, so this is > non-portable. That's formally true, but practically, I don't know of any Ada compilers that don't implement Ada.Task_Identification. An Ada compiler vendor needs something like it for debugging tasking programs, and it would be silly to create something different for that job. > Second, the contents of the string returned by Image are implementation > defined. One particular compiler uses the task name as part of the > returned value, but others might not, so adding another layer of > non-portability. Right. Janus/Ada uses "@nnnn", where "nnnn" is a task number (they're all assigned integers by our task supervisor). The task supervisor doesn't know anything about the names used in the program (its much lower level than that). But the *real* problem is having a unique identification for each task without having to worry about the task type. There might an additional level of work to figure out which task object is associated with which identifier string, but that's easily handled by printing out the id for each task when it starts. Randy.