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: 103376,651d9b748faab5c6,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!ilaria.aioe.org!aioe.org!not-for-mail From: Thomas Ruschival Newsgroups: comp.lang.ada Subject: Newbie: Code isn't executed Date: Thu, 4 Aug 2005 16:10:00 +0200 Organization: disorganized Message-ID: <20050804161000.1ffa591b@localhost> NNTP-Posting-Host: aGelw64v/ZaZIFrwfarlow.domitilla.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org NNTP-Posting-Date: Thu, 4 Aug 2005 14:10:04 +0000 (UTC) X-Newsreader: Sylpheed-Claws 1.9.12 (GTK+ 2.6.4; i686-pc-linux-gnu) Xref: g2news1.google.com comp.lang.ada:3956 Date: 2005-08-04T16:10:00+02:00 List-Id: Hello Ada group I am a student learning Ada at university. I played with some tasks that want to join another task for a rendevouz, its a modiefied exaple from the lectures. Basically I let 2 tasks sleep a different amount of time then wake up and execute a piece of code with another task during a rendevouz, I count the number how often a task got executed. Somehow a piece of code never gets executed - neither me nor nor my tutor has a clue why -- here is the code: Thanks for _ANY_ comments - I know this isn't the best way of coding - but it was just meant as an example until strange things happened Thomas with Ada.Text_IO; use Ada.Text_IO; procedure myfirst is type Name is (Peter,Michael); type Statistics is array(Name) of Integer; Partner : Name; Stat : Statistics :=(others => 0); Total: Positive :=1000; task Michael_task; task Peter_task; task Susan is entry Dinner; end Susan; task body Peter_task is begin while Total > 0 loop Put("Peters turn"); New_Line; Partner := Peter; Susan.Dinner; delay 0.002; end loop; end Peter_task; task body Michael_task is begin while Total > 0 loop Put("Michaels turn"); New_Line; Partner := Michael; Susan.Dinner; delay 0.001; end loop; end Michael_task; task body Susan is begin while Total > 0 loop Put("susans turn"); New_Line; accept Dinner do stat(Partner) := stat(Partner)+1; Put("Susan is having dinner with...."& Name'Image(Partner)); New_Line; end Dinner; Total := Total-1; end loop; -- THIS WILL NEVER BE EXECUTED --- WHY ?????????????????????? Put("Statistics:"); New_Line; Put("---------------------------------------------"); New_Line; Put("Peter: "&Integer'Image(Stat(Peter))); New_Line; Put("Michael: "&Integer'Image(Stat(Michael))); New_Line; Put("---------------------------------------------"); New_Line; end Susan; begin -- Procedure null; end myfirst;