comp.lang.ada
 help / color / mirror / Atom feed
From: stt@ada-uts
Subject: Re: Question on Tasking and Text_IO
Date: 8 Jan 88 15:31:00 GMT	[thread overview]
Message-ID: <57900059@ada-uts> (raw)
In-Reply-To: 18242@grebyn.com


The LRM does not state whether during I/O other tasks may/must proceed.
If you consider I/O operations as simply very slow machine instructions,
then it is "reasonable" that no other task proceeds during I/O.
On the other hand, if you consider I/O a communication with some
independent processor running in parallel with the CPU (e.g. the
human at the keyboard, or a disk drive), then it would seem
"reasonable" that the CPU would be available for running other
tasks while the I/O operation is waiting for a response from the
"other" processor.

Obviously, most users would prefer
the "communication with independent processor" model over
the "very slow machine instruction" model, but alas, the LRM
doesn't specify which is required.  There are some folks
who feel that on philosophical grounds the "very slow machine
instruction" model is actually more logical, but they
of course would never want to use it to try to build a
highly interactive application.

In any case, one way to protect yourself is to have
an input task which checks for the presence of input
before reading it (this is possible in some O/Ss).
If no input is present, it does an Ada DELAY and checks again.
Once input is present, it reads it, causing minimal interruption
to other tasks.

Another alternative available on Unix(R) systems
(presuming you drop into C), is to set an alarm and then read input.
When the alarm expires, the "read" will return with an error,
the task may then do an Ada delay (to allow other tasks to proceed
for awhile) before retrying the alarmed read.

S. Tucker Taft
c/o Intermetrics, Inc.
Cambridge, MA  02138

       reply	other threads:[~1988-01-08 15:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <18242@grebyn.com>
1988-01-08 15:31 ` stt [this message]
1988-01-07  3:27 Question on Tasking and Text_IO Karl A. Nyberg
replies disabled

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