[comp.lang.ada] Entries with Access Types as Formal Parameters

lomow@jade.uucp (Greg Lomow) (12/21/90)

I have a question about Ada but unfortunately I don't have access
to an Ada compiler. Please forgive errors in the code example
that follows.

Consider a task with an entry that has a formal parameter of mode
"in out" which is an access type. Now consider a call to that
entry by another task where the actual parameter is an access
value that denotes a variable within the calling task. During the
execution of the accept statement the called task reads and
writes the variable denoted by the parameter.

Is the program well-defined? Or is it erroneous? If the program
is well-defined, what occurs at run-time? What if the program is
running on a distributed system and the two tasks are running on
different processors that do not have access to shared memory? If
you can, please cite references to the Ada Reference Manual.

------------------------------------------------------------

type int_access is access integer;

task a is 
  entry e(ia : in out int_access);
end;

task b;

------------------------------------------------------------

task body a is
  i : integer;
begin
  accept e(ia : int_access) do
    i := ia.all;
    ia.all := 20;
  end;
end;

task body b is
  ia : int_access;
begin
  ia := new integer(13);  
  a.e(ia);
end b;

------------------------------------------------------------
--