comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Re: task activation
Date: 1999/11/22
Date: 1999-11-22T00:00:00+00:00	[thread overview]
Message-ID: <3839d353_2@news1.prserv.net> (raw)
In-Reply-To: wccg0xyxw9v.fsf@world.std.com

In article <wccg0xyxw9v.fsf@world.std.com> , Robert A Duff 
<bobduff@world.std.com>  wrote:

> Number 1 again.  If you have a bunch of such packages, they will get
> elaborated in some order that depends on with clauses and various
> pragmas -- but when you elaborate the package body, the tasks therein
> will be activated.

OK.  Thanks for this answer.  Now another question.

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?

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?


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;


What technique was intended by the language designers to address this
issue?


--
Get the FAQs about evolution and creationism.

<http://www.talkorigins.org/origins/faqs.html>




  reply	other threads:[~1999-11-22  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 [this message]
1999-11-23  0:00     ` Mats Weber
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         ` Robert A Duff
1999-12-06  0:00         ` Simon Wright
  -- 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