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,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: Robert A Duff Subject: Re: task activation Date: 1999/11/22 Message-ID: #1/1 X-Deja-AN: 551705768 Sender: bobduff@world.std.com (Robert A Duff) References: <383733d3_1@news1.prserv.net> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1999-11-22T00:00:00+00:00 List-Id: "Matthew Heaney" writes: > It is my understanding that a task "activates" when you hit the begin > part of the block in which the task is declared: > > procedure Main is > task O is ... > task body O is ...; > begin > > end Main; > > In this example, task O activates when procedure Main reaches its begin. > > Now, suppose we wanted to activate the task earlier than that. Let's > declare O in a nested package: > > procedure Main is > package P is > task O is ...; > end; > package body P is > task body O is ...; > end; > begin > > end; > > > Does task O activate when > > 1) the elaboration of nested package P completes (hit the begin part of > P's body); that is, prior to hitting the begin part of Main. Or, > > 2) no, the nesting doesn't matter, and O still activates when you hit > the begin part of procedure Main. Number 1. > Another question: suppose package P is a library level package (and > therefore task O is a library level task). Does O get activated when > > 1) you hit the begin part of P's body; that is, prior to hitting the > begin part of Ada main subprogram Main? Or, > > 2) no, the library-levelness doesn't matter, and O still is activated > when you hit the begin part of the Ada main. 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. Another way to control the timing of activation is to put the task in the heap -- then, an allocator causes the activation, and you can put that allocator whereever you like. - Bob