"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