comp.lang.ada
 help / color / mirror / Atom feed
From: visicom!amstel!rlk@nosc.mil  (Bob Kitzberger)
Subject: Re: conditional entry call ?
Date: 23 Sep 92 17:49:11 GMT	[thread overview]
Message-ID: <rlk.717270551@amstel> (raw)

shengru@cs.uno.edu (Shengru Tu) writes:

>I know that a typical conditional entry call can be:
>	...
>	select
>		TASK_NAME.ENTRY_NAME;
>		...
>	or
>		delay 10.0;
>	end select;

Actually that's a timed entry call [ARM 9.7.3].  A conditional entry call 
[ARM 9.7.2] is:

	select
	  entry_call_statement
	  [sequence_of_statements]
	else
	  sequence_of_statements
	end select;


>But is the following code legal, where I put another entry call stmt in
>the position of "stmt":
>	  ...
>          select
>                T2.E2;
>          or
>                T3.E3;
>          end select;
>	  ...

No, it's illegal (see ARM 9.7.3: the second alternative must be a delay
alternative).  You may be thinking of:

	select
	  T2.E2;
	else
	  T3.E3;
	end select;

In which case, by ARM 9.7.2,  the first alternative's entry call will be
cancelled if not immediately possible, and the 'else' alternative will be
followed.  This can be any sequence of statements, but since it's an
entry call it will behave as a stand-alone entry call, and waits for 
rendezvous with T3.E3.  If, while blocked on the T3.E3 entry call, task T2
hits the accept for E2, it's tough cookies since the select alternative has
already been evaluated.

It may be that what you are asking for in a multi-way entry call (the
counterpart to a selective wait).  As far as I know, it can't be done in 
Ada 83.  Does anybody have a multi-way entry call solution?

	.Bob.



with text_io;
use  text_io;
procedure test is

  task t is 
    entry a;
    entry b;
  end t;

  task body t is
  begin
    accept a do
      put_line( "a");
    end a;

    accept b do
      put_line( "b");
    end b;

    delay 1.0;		-- make sure first select alternative is evaulated

    accept a do
      put_line( "a");
    end a;
  end t;


begin

  select
    t.a;		-- immediately succeeds
  else
    t.b;
  end select;

  select
    t.a;		-- not possible, call t.b
  else
    t.b;		-- succeeds
  end select;

  select
    t.a;		-- not possible, call t.b
  else
    t.b;
    -- stuck calling b here
  end select;

end test;

----------------
Bob Kitzberger          VisiCom Laboratories, Inc.
rlk@visicom.com         10052 Mesa Ridge Court, San Diego CA 92121 USA
                        +1 619 457 2111    FAX +1 619 457 0888

             reply	other threads:[~1992-09-23 17:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-09-23 17:49 Bob Kitzberger [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-09-23 21:08 conditional entry call ? Dave Marshall
replies disabled

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