[comp.lang.ada] All possible results?

ie53@NTSUVAX.BITNET (HAERIM LEE) (09/04/87)

-- What are all possible results of the execution of the following
-- code on BOTH a single processor system and a multi-processor system?
-- Can an exception 'TASKING_ERROR' be raised at (***)?  Or will "accepted"
-- be ALWAYS printed on the screen?  Or sometimes printing "accepted" and
-- sometimes raising 'TASKING_ERROR' will occur?  Please consider BOTH
-- systems mentioned above.  Send any comments to IE53@NTSUVAX.

with text_io; use text_io;
procedure kill is
  task a is
    entry e;
  end a;
  task body a is
  begin
    select
        accept e do
          put_line("accepted");
        end e;
    or
        terminate;
    end select;
  end a;
begin
  a.e;          -- ***
end kill;

Mendal@SIERRA.STANFORD.EDU (Geoff Mendal) (09/04/87)

"accepted" must be printed no matter what implementation the
program is executed on.  TASKING_ERROR cannot occur as a result
of kill calling t.a (at least, not in this simple program).

The semantics of the terminate alternative guarantee that the task
(task a) cannot complete while any other task (in this case, the
thread of control executing procedure kill) can call one of a's
entries.  For details, read RM 9.4 and 9.7.1(10).

gom
-------