comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: tasks and protected types
Date: 29 Apr 2005 12:23:05 -0400
Date: 2005-04-29T12:23:05-04:00	[thread overview]
Message-ID: <wccy8b1r1qu.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: d4tf4s$m03$1@kda-news.kongsberg.com

"Egil H. H�vik" <egil.harald.hoevikNOSPAM@REMOVEkongsberg.com> writes:

> >
> > RM 9.5.2(26):
> > ...
> > When an exception is propagated from the handled_sequence_of_statements of
> > an accept_statement,
> > the same exception is also raised by the execution of the corresponding
> > entry_call statement.
> >
> >
> > Which means that D1.Start raises an exception, D2.Start is never called,
> and
> > Manage will wait for D2 to terminate
> > (D1 will terminate due to the unhandled exception)

That's right.

> ... and as an accept_statement contains a handled_sequence_of_statements,
> you can
> add the exception handler in the accept statement directly, thus:
> 
> accept Start( Str : in String; Tm : in Positive) do
>    Msg := Str;
>    Times := Tm;
> exception
>    when others =>
>       Ada.Text_IO.Put_Line("Exception caugth in accept statement");
> end Start;

That's not a good idea.  The exception we're talking about here is a
*bug*.  There's no way the task can recover from it.  In the original
example, if you added the above exception handler, the very next thing
the task will do is look at Times, which is an uninitialized variable!

If you want to print a message, follow it by "raise;" or something.

Unfortunately, that doesn't work at the end of a task body.
You can call the C 'exit' routine, or you 'abort' things,
or whatever, but an unhandled exception in a task body causes
it to terminate -- in most implementations, to *silently* terminate.
And then the rest of the system usually hangs.

Alternatively, you can debug this in a debugger.  Tell it to break on
all exceptions, and it will stop at the point of "Msg := Str;",
and then you can figure out what's going on.

- Bob



  reply	other threads:[~2005-04-29 16:23 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-29  4:04 [newbie question] tasks and protected types fabio de francesco
2005-04-29  7:25 ` tmoran
2005-04-29  9:43 ` Jacob Sparre Andersen
2005-04-29 10:34   ` Alex R. Mosteo
2005-04-29 11:23     ` Jacob Sparre Andersen
2005-04-29 12:18       ` Adrien Plisson
2005-04-29 12:45         ` Ada.Text_IO and protected objects (Was: [newbie question] tasks and protected types) Jacob Sparre Andersen
2005-04-29 13:22           ` Poul-Erik Andreasen
2005-04-29 14:26           ` Egil H. H�vik
2005-04-29 20:28             ` Jacob Sparre Andersen
2005-04-29 20:39             ` Randy Brukardt
2005-04-29 21:23               ` Lionel Draghi
2005-04-29 22:11                 ` fabio de francesco
2005-04-30  3:45                   ` Jeffrey Carter
2005-04-30  7:21                   ` Lionel Draghi
2005-05-02  8:11                 ` Jean-Pierre Rosen
2005-04-30 12:47               ` Ada.Text_IO and protected objects Stephen Leake
2005-04-29 21:57             ` Ada.Text_IO and protected objects (Was: [newbie question] tasks and protected types) fabio de francesco
2005-04-30  9:07               ` Ada.Text_IO and protected objects Jacob Sparre Andersen
2005-04-30 10:21                 ` Dmitry A. Kazakov
2005-05-02 10:41                   ` fabio de francesco
2005-05-02 14:10                     ` Jacob Sparre Andersen
2005-05-02 16:29                       ` fabio de francesco
2005-04-29 15:23           ` Ada.Text_IO and protected objects (Was: [newbie question] tasks and protected types) Björn Lundin
2005-04-29 12:54       ` [newbie question] tasks and protected types Alex R. Mosteo
2005-04-29 10:47   ` fabio de francesco
2005-04-29 11:33     ` Jacob Sparre Andersen
2005-04-29 12:55       ` Alex R. Mosteo
2005-04-29 14:06         ` Egil H. H�vik
2005-04-29 14:12           ` Egil H. H�vik
2005-04-29 16:23             ` Robert A Duff [this message]
2005-04-29 20:19           ` Jacob Sparre Andersen
2005-04-30 11:58           ` Simon Wright
replies disabled

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