From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e3ad0eba55db3514 X-Google-Attributes: gid103376,public From: Mats Weber Subject: Re: task activation Date: 1999/11/23 Message-ID: <383A5973.1678A675@mail.com>#1/1 X-Deja-AN: 551988899 Content-Transfer-Encoding: 7bit References: <383733d3_1@news1.prserv.net> <3839d353_2@news1.prserv.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sunrise.ch X-Trace: news1.sunrise.ch 943348084 3917 195.141.231.162 (23 Nov 1999 09:08:04 GMT) Organization: sunrise communications ag Mime-Version: 1.0 NNTP-Posting-Date: 23 Nov 1999 09:08:04 GMT Newsgroups: comp.lang.ada Date: 1999-11-23T09:08:04+00:00 List-Id: 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;