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-Thread: a07f3367d7,5cc10500d0b7a280 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!a21g2000yqc.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: task model Date: Thu, 15 Oct 2009 11:00:17 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <04458a0b-1e58-478b-a2f0-c47226f840ac@f16g2000yqm.googlegroups.com> NNTP-Posting-Host: 94.108.220.126 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1255629617 11715 127.0.0.1 (15 Oct 2009 18:00:17 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 15 Oct 2009 18:00:17 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a21g2000yqc.googlegroups.com; posting-host=94.108.220.126; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.14) Gecko/2009091008 Iceweasel/3.0.14 (Debian-3.0.14-1),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8702 Date: 2009-10-15T11:00:17-07:00 List-Id: Michael Tabak wrote on comp.lang.ada: > I'm prototyping some tasking with multiple accepts, the code is as > follows: > > with Ada.Text_Io; > use Ada.Text_Io; > > procedure task_test is > > =A0 =A0procedure Process_Primary(node: in Integer) is > > =A0 =A0begin > > =A0 =A0 =A0 =A0Put_Line("This is number" & Integer'Image(node)); > > =A0 =A0end Process_Primary; > > =A0 =A0task proc1 is > =A0 =A0 =A0entry process1(node : Integer); > =A0 =A0 =A0entry continue; > =A0 =A0end proc1; > > =A0 =A0task body proc1 is > =A0 =A0begin > > =A0 =A0 =A0accept process1( node : Integer) do > > =A0 =A0 =A0 =A0Process_Primary( node ); > > =A0 =A0 =A0end; > > =A0 =A0 =A0accept continue do > =A0 =A0 =A0 =A0Put_Line("Called Continue task1"); > =A0 =A0 =A0end; > > =A0 =A0end proc1; > > =A0 =A0task proc2 is > =A0 =A0 =A0entry process2(node : Integer); > =A0 =A0 =A0entry continue; > =A0 =A0end proc2; > > =A0 =A0task body proc2 is > =A0 =A0begin > > =A0 =A0 =A0accept process2( node : Integer) do > > =A0 =A0 =A0 =A0 =A0Process_Primary( node ); > > =A0 =A0 =A0end; > > =A0 =A0 =A0accept continue do > =A0 =A0 =A0 =A0Put_Line("Called Continue task2"); > =A0 =A0 =A0end; > > =A0 =A0end proc2; > > begin > =A0 for i in 1..2 loop > =A0 =A0proc1.process1(1); > =A0 =A0proc2.process2(2); > =A0 =A0proc1.continue; > =A0 =A0proc2.continue; > =A0 end loop; > end task_test; > -------------------------------------------------------------------------= -------------------------------------------- > > I get the out put I expect: > > This is number 1 > This is number 2 > Called Continue task1 > Called Continue task2 > > But I also get the following error which I can't track down: > > raised TASKING_ERROR : s-tasren.adb:486 Your expectations are wrong :) Your environment task contains a loop calling each task four times: for each task the call sequence is processN, continue, processN, continue. But the tasks do not contain a loop, so they can accept only the first two entry calls and then they terminate. So the second call to process1 raises Tasking_Error because task1 has terminated by now. HTH -- Ludovic Brenta.