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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,e8e240cec570cdf2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-19 01:25:03 PST Path: supernews.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!213.56.195.71!fr.usenet-edu.net!usenet-edu.net!oleane.net!oleane!nnrp.oleane.net!not-for-mail From: "Jean-Pierre Rosen" Newsgroups: comp.lang.ada Subject: Re: Multiple entry tasks Date: Thu, 19 Apr 2001 10:17:58 +0200 Organization: Adalog Message-ID: <9bm76r$mf6$1@s1.read.news.oleane.net> References: <9bkevj$61k$1@nh.pace.co.uk> NNTP-Posting-Host: mailhost.axlog.fr X-Trace: s1.read.news.oleane.net 987668507 23014 195.25.228.57 (19 Apr 2001 08:21:47 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Thu, 19 Apr 2001 08:21:47 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Xref: supernews.google.com comp.lang.ada:6991 Date: 2001-04-19T10:17:58+02:00 List-Id: "Marin David Condic" a �crit dans le message news: 9bkevj$61k$1@nh.pace.co.uk... > Sounds like you want some version of guarded entries in a select statement. > I have not attempted to do this before (kids: don't try this at home - we > *are* trained professionals!), nor have I run this past a compiler (spank me > for this later if it doesn't work) but I *think* you want some version of > the following: > > select > when (Entry2'Count <= 0) and (Entry1'Count <= 0) => > accept Entry3 ; > when (Entry1'Count <= 0) => > accept Entry2 ; > or > accept Entry1; > else > terminate; > end select ; > This is wrong. Guards are evaluated only when the select is entered (unlike POs), therefore if a task cancels its call (through timed entry call) while the guards are being evaluated, you may end up in a situation of infinite blocking. The 'Count attribute should be used only with great care outside a PO. The proper way of checking if a queue is empty is to use the else part of the select statement. Therefore: select accept Entry1; else select accept Entry2; else select accept Entry1; or accept Entry2; or accept Entry3; or terminate; end select; end select; end select; Now, an exercise to see who is following. Those who attended an Adalog training session are excluded from the competition :-) 1) Show that the sequence above exhibits a race condition 2) Show that the race condition is perfectly acceptable. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr