From: Mats Weber <matsw@mail.com>
Subject: Re: task activation
Date: 1999/11/23
Date: 1999-11-23T09:08:04+00:00 [thread overview]
Message-ID: <383A5973.1678A675@mail.com> (raw)
In-Reply-To: 3839d353_2@news1.prserv.net
Matthew Heaney wrote:
> A few posts ago Robert Dewar made a comment about the problems you can
> have if you call a procedure as soon as the task has activated. For
> example:
>
> with P;
> package body Q is
>
> task O;
>
> task body O is
> begin
> P.Op;
> end;
>
> end Q;
>
> I think what Robert was saying was that you have no guarantee that the
> body of P has been elaborated yet. So if (activated) task O tries to
> call an operation provided by P, then you can get Program_Error. Is
> this analysis correct?
Yes.
> What is the solution:
>
> 1) Elaborate(all) the packages you call, ie
>
> with P;
> pragma Elaborate_All (P);
>
> package body Q is
>
> task O;
>
> task body O is
> begin
> P.Op;
> end;
>
> end Q;
>
> Will this work OK? Or will it constrain the elaboration order
> unnecessarily?
It will work OK, and Elaborate_All is just the right pragma, you need no
more, no less.
> 2) No, don't elaborate the packages. Wait to be told (by the Ada main
> perhaps, which follows elaboration of all packages) that it's OK to
> start:
>
> with P;
> package body Q is
> protected Initialization is
> procedure Signal;
> entry Wait;
> private
> OK_To_Start : Boolean := False;
> end;
> ...
> task body O is
> begin
> Initialization.Wait;
> P.Op;
> end;
>
> end Q;
That will work fine too , but you can do it without a protected object:
package P is
procedure Start; -- to be called after elaboration.
end P;
with P;
package body Q is
task O is
entry Start;
end O;
procedure Start is
begin
O.Start;
end;
task body O is
begin
accept Start;
P.Op;
end;
end Q;
next prev parent reply other threads:[~1999-11-23 0:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-11-20 0:00 task activation Matthew Heaney
1999-11-21 0:00 ` Jean-Pierre Rosen
1999-11-22 0:00 ` Robert A Duff
1999-11-22 0:00 ` Matthew Heaney
1999-11-23 0:00 ` Mats Weber [this message]
1999-11-23 0:00 ` Matthew Heaney
1999-12-02 0:00 ` Ehud Lamm
1999-12-03 0:00 ` Simon Wright
1999-12-06 0:00 ` Robert Dewar
1999-12-06 0:00 ` Robert Dewar
1999-12-06 0:00 ` Simon Wright
1999-12-06 0:00 ` Robert A Duff
-- strict thread matches above, loose matches on Subject: below --
2011-12-21 11:58 Task activation tonyg
2011-12-21 12:27 ` tonyg
2011-12-21 12:31 ` AdaMagica
2011-12-21 12:35 ` Niklas Holsti
2011-12-22 8:26 ` tonyg
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox