comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!news2
Subject: semantics question about SELECT statement
Date: 5 Mar 93 14:52:21 GMT	[thread overview]
Message-ID: <1993Mar5.145221.23827@greco-prog.fr> (raw)

Hello Netters,

I have a question about guard evaluation in select statements.
Let us consider the piece of code below, excerpt from Ada Rationale,
section 13.2.11.

Let us assume this select is nested into a loop. Let us assume that at
some time all the guards of the select statement are opened, but no
rendez-vous is possible. Then, according to Reference Manual, section
9.7.1, the task waits on the open alternatives for a rendez-vous.

Let us assume now that two requests arrive at the same time but with
different priorities (e.g. URGENT and MEDIUM).

The question is: WHICH ONE OF THE TWO CLIENTS WILL BE SERVICED FIRST?
>From the Reference Manual, it seems to me that the clients **in that
case** are serviced in an arbitrary order (because the guards are not
reevaluated). 

It seems to me that the example below is OK only if the rendez-vous
are serviced in the textual order, i.e. the callers on the entry
REQUEST(URGENT) are serviced before the callers on the entry
REQUEST(MEDIUM), and so on, even when all the guards are opened and
several rendez-vous are possible on different entries.

Am I right, or am I missing something ?

----------------------------------------------------------------
   type LEVEL is (URGENT, MEDIUM, LOW);

   
   task CONTROL is
     entry REQUEST(LEVEL)(D :  DATA);
   end;
   
   task body CONTROL is
     ...
     select
       accept REQUEST(URGENT)(D :  DATA) do
         ...
       end;
     or when REQUEST(URGENT)'COUNT = 0 =>
       accept REQUEST(MEDIUM)(D :  DATA) do
         ...
       end;
     or when REQUEST(URGENT)'COUNT = 0
       and   REQUEST(MEDIUM)'COUNT = 0 =>
       accept REQUEST(LOW)(D :  DATA) do
         ...
       end;
     end select;
     ...
   end CONTROL;
----------------------------------------------------------------


--
Miguel ALABAU
Universite BORDEAUX I - LaBRI
351, cours de la Liberation   33405 TALENCE CEDEX (FRANCE)      
phone: (33) 56-84-69-35 / fax: (33) 56-84-66-69
e-mail: alabau@geocub.greco-prog.fr / alabau@labri.u-bordeaux.fr

             reply	other threads:[~1993-03-05 14:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-03-05 14:52 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!news2 [this message]
1993-03-07 21:08 ` semantics question about SELECT statement (typos fixed) Alex Blakemore
1993-03-08 19:44 ` semantics question about SELECT statement Robert I. Eachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox