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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,651d9b748faab5c6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 04 Aug 2005 21:40:18 -0500 From: "Steve" Newsgroups: comp.lang.ada References: <20050804161000.1ffa591b@localhost> Subject: Re: Newbie: Code isn't executed Date: Thu, 4 Aug 2005 19:43:09 -0700 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original Message-ID: NNTP-Posting-Host: 24.22.63.157 X-Trace: sv3-egZjpMiC23gbcm6E+QbjbiBpLtGDPizOjvzIToDfeuH0cvnIZyamy4tF1d5NrwS9McbG8Uaq0cHSoY0!pECybGy/MvL8Nv35qK04FAWnUANwdyhbSwvVjGnTXmTbRGqxRBuC9zlAz8MGgw7D3uvoOWTsC74= X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news1.google.com comp.lang.ada:3974 Date: 2005-08-04T19:43:09-07:00 List-Id: "Thomas Ruschival" wrote in message news:20050804161000.1ffa591b@localhost... > 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 > First: I recommend you add something like: EXCEPTION WHEN Reason: OTHERS => Ada.Text_IO.Put( "EXCEPTION NAME: " & Exception_Name( Reason) ); Ada.Text_IO.Put( "EXCEPTION MESSAGE: " & Exception_Message( Reason) ) ); Ada.Text_IO.Put( "EXCEPTION INFORMATION: " & Exception_Information( Reason) ) ); To the end of each of task body, at least for experimenting. This helps to eliminate the problem of tasks dying quietly. Second: You may be aware of this, but there are a lot of holes in the program. It is generally not safe to have 2 tasks manipulating the same global memory without the use of a protected type. In your example, I think it would make more sense to pass information to Susan at Dinner: task Susan is entry Dinner( Partner : Name ); end Susanl ... Then instead of: Partner := Peter; Susan.Dinner; use: Susan.Dinner( Peter ); Also, it is a good idea to avoid doing much inside a rendevous other than moving data around, so I would suggest changing: dinnerPartner : Name; ... accept Dinner( Partner : Name ) do dinnerPartner := Partner; end Dinner stat(dinnerPartner ) := stat(dinnerPartner )+1; Put("Susan is having dinner with...."& Name'Image(dinnerPartner )); New_Line; During the rendevous only one of the threads runs, so I suggest getting it over as soon as possible. Steve (The Duck)