comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: task synchronization and activation
Date: 22 Feb 2005 21:24:58 -0500
Date: 2005-02-22T21:24:58-05:00	[thread overview]
Message-ID: <wccacpwovwl.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 3bmevc.5mi.ln@hunter.axlog.fr

Jean-Pierre Rosen <rosen@adalog.fr> writes:

> Robert A Duff a �crit :
> [...]
> > I can believe that that was the reasoning of the Ada 83 designers.
> > But I still don't quite agree with it.
> > For one thing, if you want to handle exceptions in the decl part,
> > just change this:
> >     task body T is
> >         ... -- possible exception here?
> >     begin
> >         ...
> >     end T;
> > to this:
> >     task body T is
> >     begin
> >         declare
> >             ... -- possible exception here?
> >         begin
> >             ...
> >         end;
> >     exception
> >         ...
> >     end T;
> > and now the task can handle it (because it's no longer in the task's
> > declarative part).  So it's a case of "Doctor, it hurts when I...."
> > "So don't do that."  ;-)
> 
> It is not the same thing *at all*. Here, you are putting the
> responsibility on the task's side, but the issue is to be safe from the
> caller's point of view.
> 
> Let's look at it differently. A program unit needs some subtasks to do
> its job. If the subtasks cannot be started for any reason (including
> storage_error), then the program unit cannot work, and it'd better be
> noticed of that; most likely, the program unit will raise an exception
> or find a fall-back strategy. Since asynchronous exceptions are horrible
> (Java did that mistake, and had to back-up), this must happen
> synchronously, and the logical point is just before executing any
> statement.
> 
> Now, you can argue that the subtasks may fail at any later time;

Yes, I do argue exactly that.  ;-)

>... that's
> true, and Tasking_Error may be raised for any interaction. However,
> failing activation is basically not having the resources to start the
> servers, and is a much more severe condition.

Failing activation (i.e. raising an exception before "begin") could be
due to lack of resources, or a bug, or any other cause of exceptions.
Exceptions *after* "begin" can also be caused by any of these --
including running out of resources.  So I don't see any reason to
believe that exceptions before the begin are more severe, or deserve an
automatic means of notification -- let the programmer decide which
exceptions are severe, and how/who should be notified.

Actually, I'd say exceptions in an exception handler are typically more
severe than others, because they represent failure of a failure-recovery
mechanism.  But I still think the programmer, not the language designer,
should make such decisions.

Anyway, passing the "begin" is no indication that the task is ready to
go.  Putting code before and after "begin" is determined by all kinds of
unrelated issues (like if you want to call a subprogram that creates a
String, you normally have to use a function result, rather than an 'out'
parameter, so it comes before "begin", whereas if you want to initialize
a variable with a loop, that comes after "begin").  A task is ready to
receive entry calls when it reaches an accept -- "begin" is irrelevant.

- Bob



  reply	other threads:[~2005-02-23  2:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-19 15:11 task synchronization and activation Evangelista Sami
2005-02-19 16:11 ` Martin Krischik
2005-02-19 18:11   ` Ed Falis
2005-02-19 20:05   ` Robert A Duff
2005-02-20 10:47     ` Martin Krischik
2005-02-21 19:25     ` Dmitry A. Kazakov
2005-02-21  8:50 ` Jean-Pierre Rosen
2005-02-21 21:55   ` Robert A Duff
2005-02-22  0:01     ` Randy Brukardt
2005-02-22  7:17     ` Jean-Pierre Rosen
2005-02-23  2:24       ` Robert A Duff [this message]
2005-02-23  7:58         ` Martin Krischik
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox