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 13:43:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn14feed!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 13:33:44 -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: 7 Dec 2002 21:43:04 GMT User-Agent: KNode/0.6.1 X-noarchive: yes Xref: archiver1.google.com comp.lang.ada:31536 Date: 2002-12-07T21:43:04+00:00 List-Id: arvids lemchens fed this fish to the penguins on Saturday 07 December 2002 04:16 am: > type TCPtr is access TC; > type TList is array (Positive range <>) of TCPtr; > CList : TList(1..10000); > Let's see, you create an array of pointers capable of accessing 10_000 copies of the task... > begin > CList(1) := new TC; But you only create ONE task in the main body > Put("Start Task S at: "); > Put(Long_Long_Integer(Seconds(Clock))); > New_Line; > CList(1).S(60); You then call a rendezvous entry, which means main body holds here until the task exits the accept block -- but the accept block contains a delay statement so both the main body and the task basically do nothing for a while, then the task does its output and finishes the accept block, at which point the main body continues (and the task goes back to waiting for another entry call to be made). > Put("End Task S "); > Put(Long_Long_Integer(Seconds(Clock))); > New_Line; > Put("Start Task U "); > Put(Long_Long_Integer(Seconds(Clock))); > New_Line; > CList(1).S(120); And now you make a second rendezvous with the SAME task. > Put("End Task U "); > Put(Long_Long_Integer(Seconds(Clock))); > New_Line; > end tt; Looks like it's doing just what you asked for (which may not be what you meant). The following hacked version of your code (and I see that if I do much Ada work in Mandrake I'm going to have to figure out how to set the default vim tab stops to 4) with Ada.Text_IO; use Ada.Text_IO; with Ada.Calendar; use Ada.Calendar; with Ada.Long_Long_Integer_Text_IO; use Ada.Long_Long_Integer_Text_IO; Procedure tt is task type TC is entry S(D : Positive); end TC; task body TC is delayID : Positive; begin Put("a TC task has initiated"); New_Line; loop select Accept S(D : In Positive) do delayID := D; end S; or terminate; end select; delay Standard.duration(delayID); Put("Task "); Put(Long_Long_Integer(delayID)); Put(" has finished at "); Put(Long_Long_Integer(Seconds(Clock))); New_Line; end loop; end TC; TC_one, TC_two : TC; begin Put("Start Task TC_one at: "); Put(Long_Long_Integer(Seconds(Clock))); New_Line; TC_one.S(120); Put("Start Task TC_two at: "); Put(Long_Long_Integer(Seconds(Clock))); New_Line; TC_two.S(60); Put("Both tasks should be running"); New_Line; end tt; generates the following output: [wulfraed@beastie wulfraed]$ ./tt a TC task has initiated Start Task TC_one at: 48526 Start Task TC_two at: 48526 a TC task has initiated Both tasks should be running Task 60 has finished at 48586 Task 120 has finished at 48646 Note: I get lucky, and the I/O overlap managed to appear at the newlines, but with slightly different overhead, it is possible that the "a TC task has initiated" could appear between the "... at: " and " " output. Also note that I made TC_one run for the longer period of time -- > ============================================================== < > 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/ <