comp.lang.ada
 help / color / mirror / Atom feed
* asynchronos select question
@ 2001-10-25  9:54 Paolo Argenton
  2001-10-25 18:57 ` Ted Dennison
  2001-10-25 23:30 ` Peter Hend�n
  0 siblings, 2 replies; 5+ messages in thread
From: Paolo Argenton @ 2001-10-25  9:54 UTC (permalink / raw)


Just learning Ada in my spare time, so please be patient.. ;-)
I have the following question, regarding the select then abort usage:

if I try the following snippet, inspired by the AARM example

select
    delay 5.0;
    put_line (" timeout" );
then abort
    proc_with_blocking_io; -- i.e. wait for a byte to come from a serial
line for istance
end select;

it never triggers the timeout part and waits forever, at least on NT+gnat
3.13.
Is it correct ? incorrect ? my misunderstanding ? compiler/OS dependant code
?
thanks in advance

Paolo Argenton
paoloa1@yahoo.com






^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: asynchronos select question
  2001-10-25  9:54 asynchronos select question Paolo Argenton
@ 2001-10-25 18:57 ` Ted Dennison
  2001-10-25 23:30 ` Peter Hend�n
  1 sibling, 0 replies; 5+ messages in thread
From: Ted Dennison @ 2001-10-25 18:57 UTC (permalink / raw)


In article <9r8nmb$l2j$1@e3k.asi.ansaldo.it>, Paolo Argenton says...
>select
>    delay 5.0;
>    put_line (" timeout" );
>then abort
>    proc_with_blocking_io; -- i.e. wait for a byte to come from a serial
>line for istance
>end select;
>
>it never triggers the timeout part and waits forever, at least on NT+gnat

I haven't actually ever used this construct before (heck, I'd fogotten it
existed). But I'd guess that an abort of the abortable part is only possible
while you are within the language. If your Win32 thread is blocked waiting for
an I/O at the Operating System level, there is nothing Ada can do for you. So
what would probably happen here is that you will sit forever waiting for that IO
to complete. Once it does, the abortable part will get aborted, and you'd see
your "timeout" string (assuming there is still some Ada to execute after the I/O
completes).

For what you seem to be attempting to do, I think I'd use a task and a protected
type. The task services the I/O source, and the protected type implements a
queue of data read from the source. Then you can use a conditional or timed
entry call to read the data from the protected type (queue).

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html

No trees were killed in the sending of this message. 
However a large number of electrons were terribly inconvenienced.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: asynchronos select question
  2001-10-25  9:54 asynchronos select question Paolo Argenton
  2001-10-25 18:57 ` Ted Dennison
@ 2001-10-25 23:30 ` Peter Hend�n
  2001-11-02  4:17   ` David Brown
  2001-11-02 11:15   ` Robert Dewar
  1 sibling, 2 replies; 5+ messages in thread
From: Peter Hend�n @ 2001-10-25 23:30 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1264 bytes --]

"Paolo Argenton" wrote:
<snip>
> select
>     delay 5.0;
>     put_line (" timeout" );
> then abort
>     proc_with_blocking_io; -- i.e. wait for a byte to come from a serial
> line for istance
> end select;

> it never triggers the timeout part and waits forever, at least on NT+gnat
> 3.13. Is it correct ? incorrect ? my misunderstanding ? compiler/OS
> dependant code ?
Check out "pragma Polling" in the GNAT Reference Manual and the switch
-gnatP in the User's Guide. An asynchronous abort will not work at all under
NT without pragma polling (ON).

In this particular case it will not work correctly (at least not under NT)
anyway. The blocking_io call is "outside the reach" of Ada, since
no polling can take place with the process blocked in I/O.

If you replace the blocking io call with a very time-consuming calculation,
it will work just fine with Polling (ON) but not with (OFF) - the default.

Just a question to those who might know. Is this behaviour conforming
to the standard? I can see no reason in the ARM for not being able
to abort a blocking io operation. Does it work on other platforms?

Regards,
Peter H.

--
Peter Hend�n           http://www.algonet.se/~phenden
ICQ: 14672398
Teknisk Dokumentation AB          http://www.tdab.com






^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: asynchronos select question
  2001-10-25 23:30 ` Peter Hend�n
@ 2001-11-02  4:17   ` David Brown
  2001-11-02 11:15   ` Robert Dewar
  1 sibling, 0 replies; 5+ messages in thread
From: David Brown @ 2001-11-02  4:17 UTC (permalink / raw)


"Peter Henden" <phenden@tdab.com> wrote:
> "Paolo Argenton" wrote:
> <snip>
>> select
>>     delay 5.0;
>>     put_line (" timeout" );
>> then abort
>>     proc_with_blocking_io; -- i.e. wait for a byte to come from a serial
>> line for istance
>> end select;

> Just a question to those who might know. Is this behaviour conforming
> to the standard? I can see no reason in the ARM for not being able
> to abort a blocking io operation. Does it work on other platforms?

This works on arch's such as Linux, where abort is implemented with a
signal.

I understand that NT doesn't really provide a way for one task to
"signal" another task, so there isn't really any way to implement this
in NT.

Dave Brown



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: asynchronos select question
  2001-10-25 23:30 ` Peter Hend�n
  2001-11-02  4:17   ` David Brown
@ 2001-11-02 11:15   ` Robert Dewar
  1 sibling, 0 replies; 5+ messages in thread
From: Robert Dewar @ 2001-11-02 11:15 UTC (permalink / raw)


"Peter Hend?" <phenden@tdab.com> wrote in message news:<ig1C7.2344$R43.409545@newsb.telia.net>...
> Just a question to those who might know. Is this behaviour conforming
> to the standard? I can see no reason in the ARM for not being able
> to abort a blocking io operation. Does it work on other platforms?



See RM 1.1.3(6) second part



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-11-02 11:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-25  9:54 asynchronos select question Paolo Argenton
2001-10-25 18:57 ` Ted Dennison
2001-10-25 23:30 ` Peter Hend�n
2001-11-02  4:17   ` David Brown
2001-11-02 11:15   ` Robert Dewar

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