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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5400c39557b9f344 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-07 16:22:14 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn14feed!wn12feed!wn11feed!worldnet.att.net!207.217.77.102!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!harp.news.atl.earthlink.net!beastie.ix.netcom.com!nobody From: Dennis Lee Bieber Newsgroups: comp.lang.ada Subject: Re: Multitasking Date: Sat, 07 Dec 2002 16:17:22 -0800 Organization: >> Leaf-Eating Penguins? << Message-ID: References: <8bRwOT7FACB@lemmies.lb.bawue.de> NNTP-Posting-Host: d1.56.01.04 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Server-Date: 8 Dec 2002 00:26:55 GMT User-Agent: KNode/0.6.1 X-noarchive: yes Xref: archiver1.google.com comp.lang.ada:31543 Date: 2002-12-08T00:26:55+00:00 List-Id: Dennis Lee Bieber fed this fish to the penguins on Saturday 07 December 2002 01:33 pm: > [wulfraed@beastie wulfraed]$ ./tt > a TC task has initiated > Start Task TC_one at: 48526 > Start Task TC_two at: 48526 Hmmm, using whole seconds (and why Long_Long yet?) hides some of the timing granularity. Let's try again with a bit more detail, and a second invocation of the entry calls so you can see the effect of a rendezvous blocking action. Try this one, which overlaps a few invocations to each task. (My apologies for the clumsy myPutFloat definition -- no doubt there is a more efficient way of doing the same without coding the fore/aft/exp arguments on all calls -- while I've always liked the language [did a presentation on Ada in my senior year, before the it had even been finalized as a DOD standard] I've never really /used/ the language). with Ada.Text_IO; use Ada.Text_IO; with Ada.Calendar; use Ada.Calendar; with Ada.Float_Text_IO; use Ada.Float_Text_IO; Procedure tt is procedure myPutFloat(F : Float) is begin Put(F, Fore=>6, Aft=>5, Exp=>0); end; task type TC is entry S(D : Positive); end TC; task body TC is delayID : Positive; begin Put("a TC task has initiated at: "); myPutFloat(Float(Seconds(Clock))); New_Line; loop select Accept S(D : In Positive) do myPutFloat(Float(D)); Put(" Accepted at: "); myPutFloat(Float(Seconds(Clock))); New_Line; delayID := D; end S; or terminate; end select; delay Standard.duration(delayID); Put("Task "); myPutFloat(Float(delayID)); Put(" has finished at "); myPutFloat(Float(Seconds(Clock))); New_Line; end loop; end TC; TC_one, TC_two : TC; begin Put("Rendezvous Task TC_one at: "); myPutFloat(Float(Seconds(Clock))); New_Line; TC_one.S(120); Put("Rendezvous Task TC_two at: "); myPutFloat(Float(Seconds(Clock))); New_Line; TC_two.S(60); Put("Both tasks should be running"); New_Line; Put("Rendezvous Task TC_two at: "); myPutFloat(Float(Seconds(Clock))); New_Line; TC_two.S(10); Put("Rendezvous Task TC_one at: "); myPutFloat(Float(Seconds(Clock))); New_Line; TC_one.S(20); Put("Rendezvous Task TC_two at: "); myPutFloat(Float(Seconds(Clock))); New_Line; TC_two.S(15); Put("Waiting for last task to finish"); New_Line; end tt; The results on my machine are: [wulfraed@beastie ada]$ ./tt a TC task has initiated at: 58287.18750 Rendezvous Task TC_one at: 58287.18750 120.00000 Accepted at: 58287.18750 Rendezvous Task TC_two at: 58287.19141 a TC task has initiated at: 58287.19141 60.00000 Accepted at: 58287.19141 Both tasks should be running Rendezvous Task TC_two at: 58287.19141 Task 60.00000 has finished at 58347.19141 10.00000 Accepted at: 58347.19141 Rendezvous Task TC_one at: 58347.19141 Task 10.00000 has finished at 58357.20313 Task 120.00000 has finished at 58407.19141 20.00000 Accepted at: 58407.19141 Rendezvous Task TC_two at: 58407.19141 15.00000 Accepted at: 58407.19141 Waiting for last task to finish Task 15.00000 has finished at 58422.20313 Task 20.00000 has finished at 58427.20703 -- > ============================================================== < > wlfraed@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed@dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ <