From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Strange warning message
Date: Sat, 2 Dec 2017 11:47:26 +0200
Date: 2017-12-02T11:47:26+02:00 [thread overview]
Message-ID: <f8fb5iFbe3cU1@mid.individual.net> (raw)
In-Reply-To: <lyvahpa54l.fsf@pushface.org>
On 17-12-02 10:47 , Simon Wright wrote:
> Robert Eachus <rieachus@comcast.net> writes:
>
>> For tasks, we have this additional constraint. You can't leave the
>> scope in which a task is declared because the task can still access
>> those objects. So functions, procedures, tasks and even packages can
>> need to wait for all the tasks declared locally to be completed (or
>> waiting at a terminate alternative). Again declaring library level
>> tasks, if you don't need this complex behavior, eliminates run-time
>> code to make it work.
>
> In my experience, when GNAT (with the default static elaboration) has
> been unable to find a valid elaboration order, it's almost always been
> because of library-level tasks; the binder can't tell whether the task
> (which starts executing on completion of its package's elaboration)
> actually makes any calls to with'd packages at that point, so assumes
> the worst.
That is also my experience, and I therefore isolate library-level tasks
in their own packages which do _not_ provide any public operations. For
example, if a subsystem is implemented by the data and operations in
package Foo, but also needs a library-level task, I put the task in a
child package, Foo.Tasks, which provides nothing else (so a pragma
Elaborate_Body is usually needed in the declaration of Foo.Tasks).
Only the main subprogram has context clauses "with Xxx.Tasks". No other
package refers to the Xxx.Tasks packages.
GNAT can then put all the Xxx.Tasks packages at the end of the
elaboration order (before the main subprogram) and they cause no
elaboration circularities.
Another benefit of this separation is that it becomes easy to select the
(sub)set of tasks that are included in the program. For example, unit
testing of package Foo can be performed in a sequential way by not
including Foo.Tasks in the unit-testing program.
Another approach to the elaboration problem is to use pragma
Partition_Elaboration_Policy (Sequential) to delay the activation of
library-level tasks until the end of the library elaboration. I haven't
tried that yet.
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
prev parent reply other threads:[~2017-12-02 9:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-27 8:40 Strange warning message reinert
2017-11-27 9:00 ` Jacob Sparre Andersen
2017-11-27 9:13 ` reinert
2017-11-27 9:45 ` Jacob Sparre Andersen
2017-11-27 10:43 ` reinert
2017-11-27 9:01 ` gautier_niouzes
2017-11-27 9:09 ` gautier_niouzes
2017-11-27 9:27 ` reinert
2017-11-27 10:42 ` Jeffrey R. Carter
2017-11-27 10:47 ` reinert
2017-11-27 11:52 ` reinert
2017-11-29 0:43 ` Robert Eachus
2017-11-29 10:39 ` reinert
2017-11-29 20:47 ` Randy Brukardt
2017-11-30 14:11 ` reinert
2017-12-01 22:53 ` Robert Eachus
2017-12-02 8:47 ` Simon Wright
2017-12-02 9:47 ` Niklas Holsti [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox