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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c3c4ae45442f569e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!news.glorb.com!newscon02.news.prodigy.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: tasks and protected types Date: 29 Apr 2005 12:23:05 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1114747457.868019.93210@f14g2000cwb.googlegroups.com> <1114771627.401153.78280@z14g2000cwz.googlegroups.com> <42722ECA.5060903@mailinator.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls4.std.com 1114791785 22478 192.74.137.71 (29 Apr 2005 16:23:05 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 29 Apr 2005 16:23:05 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:10824 Date: 2005-04-29T12:23:05-04:00 List-Id: "Egil H. H�vik" 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