comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adambeneschan@gmail.com>
Subject: Re: Timeouts in Ada
Date: Thu, 17 Jul 2014 13:29:11 -0700 (PDT)
Date: 2014-07-17T13:29:11-07:00	[thread overview]
Message-ID: <39a6309b-2920-4cec-818a-eb8ee46474d9@googlegroups.com> (raw)
In-Reply-To: <lq982c$t2c$2@dont-email.me>

On Thursday, July 17, 2014 12:27:07 PM UTC-7, Jeffrey Carter wrote:
> On 07/17/2014 12:38 AM, J-P. Rosen wrote:
> 
> > Not at all! In Ada, one task=one thread, there are no hidden threads.
> 
> Surely ATC involves a "hidden thread". After all,
> 
> select
>     <trigger>
> then abort
>     <abortable part>
> end select;
> 
> is shorthand for
> 
> declare
>     task AP;
>  
>     task body AP is
>     begin
>        <abortable part>
>     end AP;
> begin
>     <trigger>
>     abort AP;
> end;

Not quite.  If the <trigger> is an entry call, and the entry can be selected immediately, the <abortable part> never starts (unless the entry is requeued-with-abort); your code would have the <abortable part> start, and then get aborted when the entry call is completed.  

If the trigger is an entry call and the entry is queued, *then* the abortable part is aborted when the entry call completes, not when it's selected.  

There are other cases where the language says the abortable part would never start, but in your code above, it's nondeterministic whether your abortable part would start or not.

Anyway, it's hard to say whether this involves a "hidden thread" or not.  J-P's statement makes no sense if we're talking about low-level or OS threads, since Ada says nothing about how tasks should be implemented, and it's possible to write a tasking implementation in which there is only one OS thread in which all tasks run, and there's nothing wrong with an implementation creating a new "hidden" OS thread that is unconnected to a task if necessary.  If we're talking about a conceptual kind of "thread", then we'd need a better definition of what we're talking about.  The RM uses the term "thread of control" but never really defines it, but RM 9(1) says "Each task represents a separate thread of control that proceeds independently and concurrently between the points where it interacts with other tasks."  In the context of the original question, I think that means that within a single task, there cannot be two sequences of statements that are executing at the same time, as the OP thought there were with the SELECT statement.  How this applies to ATC, I'm not sure.  But I think it's still true that you cannot have two statements in a single task executing at the same time, as long as you don't consider a DELAY to be "executing" while it's delaying, or an entry call to be "executing" when it's waiting for a rendezvous to complete.  

                               -- Adam



  parent reply	other threads:[~2014-07-17 20:29 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17  5:18 Timeouts in Ada NiGHTS
2014-07-17  7:08 ` Simon Wright
2014-07-17  8:35   ` NiGHTS
2014-07-21 23:34   ` Randy Brukardt
2014-07-22  1:11     ` Shark8
2014-07-22  7:39       ` J-P. Rosen
2014-07-22  8:31         ` Simon Wright
2014-07-22 21:52       ` Randy Brukardt
2014-07-17  7:38 ` J-P. Rosen
2014-07-17  8:40   ` NiGHTS
2014-07-17 10:00     ` J-P. Rosen
2014-07-17 19:27   ` Jeffrey Carter
2014-07-17 19:51     ` J-P. Rosen
2014-07-17 20:52       ` Jeffrey Carter
2014-07-17 20:29     ` Adam Beneschan [this message]
2014-07-17 20:52       ` J-P. Rosen
2014-07-21 23:44         ` Randy Brukardt
2014-07-17 20:43     ` Jeffrey Carter
2014-07-21 23:37   ` Randy Brukardt
2014-07-17  7:42 ` Dmitry A. Kazakov
2014-07-17  8:59   ` NiGHTS
2014-07-17  9:48     ` Dmitry A. Kazakov
2014-07-17 17:10       ` NiGHTS
2014-07-17 20:45         ` Dmitry A. Kazakov
2014-07-17 16:12 ` Adam Beneschan
2014-07-17 16:46   ` NiGHTS
2014-07-17 17:11     ` Simon Wright
2014-07-17 17:58       ` NiGHTS
2014-07-17 19:02         ` Jeffrey Carter
2014-07-17 18:58       ` Jeffrey Carter
2014-07-17 18:12     ` Adam Beneschan
2014-07-17 19:27       ` Jeffrey Carter
2014-07-17 18:56     ` Jeffrey Carter
2014-07-23 22:37     ` Robert A Duff
2014-07-24  9:23       ` AdaMagica
2014-07-24 15:37         ` Robert A Duff
2014-07-25  5:16           ` Randy Brukardt
2014-07-25  9:11           ` AdaMagica
2014-07-25 16:15             ` Brad Moore
2014-07-25 16:34             ` Dmitry A. Kazakov
2014-07-17 19:27 ` Jeffrey Carter
replies disabled

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