From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Delayed deallocation of non-terminated task in Gnat?
Date: Wed, 31 Aug 2011 17:09:47 -0400
Date: 2011-08-31T17:09:47-04:00 [thread overview]
Message-ID: <wccmxepcmp0.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: j3m5aj$pv6$1@dont-email.me
"J-P. Rosen" <rosen@adalog.fr> writes:
> Le 31/08/2011 20:12, Robert A Duff a �crit :
>> I consider it a flaw in Ada that there's no general-purpose
>> way to block waiting for the termination of a task.
>>
> With some cooperation of the other task...
>
> Declare in the waited task an entry (Wait_For_Terminate) which is never
> accepted. The waiting task calls the entry, and gets Tasking_Error when
> the waited task terminates (for whatever reason).
We thought of that while implementing the feature that started this
thread. Unfortunately, it doesn't quite work. The Tasking_Error is
raised when the task is completed, so at the time T_E is handled, the
other task could still be going about its business doing finalization.
And even if there's no user-level finalization involved, there's still
some stuff going on in the run-time system between completion and
termination. So there's an inherent race condition here.
What I claim is missing from Ada (and is hard to implement) is a feature
that blocks a task until some other task(s) is/are really and truly
terminated, and won't execute a single 'nother instruction.
You can loop, checking 'Terminated, with a delay. But the delay is
guaranteed to be either too long or too short -- most likely both. The
feature we're talking about was implemented because there was such a
loop, and it was causing an AdaCore customer's program (with thousands
of dynamically allocated tasks) to take half an hour. After
implementing this feature, and removing the loop-with-delay, it took a
few seconds.
- Bob
next prev parent reply other threads:[~2011-08-31 21:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-30 13:22 Delayed deallocation of non-terminated task in Gnat? Marc C
2011-08-30 15:20 ` Dmitry A. Kazakov
2011-08-31 18:12 ` Robert A Duff
2011-08-31 19:23 ` Dmitry A. Kazakov
2011-08-31 20:58 ` Robert A Duff
2011-08-31 21:16 ` Jeffrey Carter
2011-08-31 20:25 ` J-P. Rosen
2011-08-31 21:09 ` Robert A Duff [this message]
2011-08-31 21:53 ` Simon Wright
2011-08-30 15:38 ` Adam Beneschan
2011-08-30 16:42 ` Dmitry A. Kazakov
2011-08-30 18:57 ` Niklas Holsti
2011-08-30 19:23 ` Dmitry A. Kazakov
2011-08-31 16:39 ` Adam Beneschan
2011-08-31 18:21 ` Robert A Duff
2011-08-31 23:28 ` Adam Beneschan
2011-09-01 11:58 ` Robert A Duff
2011-08-31 20:30 ` J-P. Rosen
2011-08-31 22:36 ` Adam Beneschan
2011-09-01 5:24 ` J-P. Rosen
2011-08-31 18:08 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox