[comp.lang.ada] Telegen Ada guard evaluation

rds@moss.ATT.COM (05/27/88)

From Dave Stein...

Our programs have
many concurrent tasks, and it seems that the TeleGen compiler is way
faulty.  For one thing, it seems that guards (i.e. when statements)
on accept statements simply do not get evaluated sometimes.

I enclose a short sample program.

...
	    select
		when (x > 10) =>
		    accept maybe do
			put_line ("we made it");
		    end;
		    exit;
	    or				-- XXX
                delay 1.0;
		x := x + 1;
		put_line ("can't accept yet");
	    end select;


With the TeleGen compiler, the program prints "we made it" then exits.
This does not seem correct to me.  When I compile this with the Verdix
Ada compiler on our Vax, the program prints "==> DEADLOCK! <== No tasks
to run, no delays waiting."  If I change the "or" marked with "XXX" to
an "else," the programs works "as expected" for both compilers, i.e.
it prints "can't accept yet" 9 times, then prints "we made it" and exits.

Anyone have any ideas?  Please email unless you feel it would be of
interest to the group as a whole.  Many thanks in advance!

P.S. If you want to try the program on your compiler, I'd be interested
to know what happens.


RESPONSE:

I ran this on DEC Ada ... worked "as expected" ( I seem to trust DEC's
Ada compiler more than most other products, sometimes even more than
the LRM).

It is interesting to note that Dave Stein reports different effects
when he replaces the "or" statement with an "else". This may be an 
indicator to the real problem. The interpretation of a delay 
statement in the original context implies that the accept alternative 
"maybe" could be accepted within one second. Using the "else" clause,
once it is determined the accept alternative is not ready for rendevous,
there must be a delay of at least one second. The execution Dave
describes is still faulty for both Telegen and Verdix, but the problem
appears to be in the implementation of the delay statement used as a
timeout facility, not a faulty guard statement.

Rich DeSimine
AT&T Bell Laboratories
(201) 386-2059

bseymour@potpourri.UUCP (Burch Seymour) (06/10/88)

in article <27110@clyde.ATT.COM>, rds@moss.ATT.COM says:
> From Dave Stein...
> 
> Our programs have concurrent tasks, and it seems that the TeleGen compiler
> is faulty.  For one thing, it seems that guards (i.e. when statements)
> on accept statements simply do not get evaluated sometimes.
> 
I am replacing the program fragment with the entire test program which
I ran.  Gould is using the Telesoft Telegen II compiler which was just
validated under the 1.9 test suite a couple of weeks ago. It works
correctly. That is it prints "can't accept yet" 11 times then the
"we made it" and exits. Here's my program:

with text_io; use text_io;

procedure tg is

task tgtask is
  entry maybe;
end;

task body tgtask is

 x : integer := 0;
    begin
      loop
	    select
		when (x > 10) =>
		    accept maybe do
			put_line ("we made it");
		    end;
                    exit;
	    or				-- XXX
                delay 1.0;
		x := x + 1;
		put_line ("can't accept yet");
	    end select;
       end loop;
end tgtask;

begin

put_line("Start test.");
 tgtask.maybe;
put_line("Ending test.");

end tg;

> it prints "can't accept yet" 9 times, then prints "we made it" and exits.

Since the original posting had only a part of the code, I don't know
what initial value x had, but if it started at zero and the test for the
accept is x>10 then the message should be printed 11 times. Only 9 messages
would indicate a starting value of x := 2; Seems like an odd place to
start, unless there was an uninitialized x variable involved which could
explain why the original test didn't work as expected on the Telegen
compiler.

-Burch Seymour- Gould CSD  FtLauderdale, Fla 
 ...uunet!gould!bseymour  or any of a host of other possibilities
------------------------------------------------------------------------