comp.lang.ada
 help / color / mirror / Atom feed
* Immediate Reading in Tasks
@ 1991-03-15 23:37 George C. Harrison, Norfolk State University
  1991-03-19  3:19 ` William Loftus
  1991-03-27 20:00 ` Use clauses in the visible parts of packages??? Scott Layson Burson
  0 siblings, 2 replies; 4+ messages in thread
From: George C. Harrison, Norfolk State University @ 1991-03-15 23:37 UTC (permalink / raw)


Ada teachers and Real-Time types - 

  I'd like some helpful hints about how to handle an "immediate get" type of
procedure in a tasking environment.  By "immediate get" (IGET) I mean the
ability to read a character directly from the keyboard without pressing the
return key.  Some, if not most, implementations of Ada have the ability to do
such a reading albeit indirectly.

Here's the "problem."  

Doing an IGET inside a task generally causes the other tasks to wait until the
user presses a key.  In my real time simulations for my students when they must
act as monitors or interrups it would be nice to have the program run with all
its tasks until a key is pressed (and then read, if necessary).

Do-While Jones in "Ada in Action" proposes a solution similar to the following:

Define a function KEYPRESSED (boolean) and an IGET procedure that only works
when KEYPRESSED is TRUE.  These subroutines call a task which essentially holds
the incoming character as the value of a local [task] variable, setting
KEYPRESSED to true until the character is retrieved from the task.

So another task might do this:

loop
  do_stuff;
  if keypressed then
    iget(ch);
    do_something_with_ch;
  else
    do_something_else;
  end if;
end loop;


I welcome any and all ideas.  I have used the Do-While Jones method, but it
seems to have a lot of overhead.  

George

-- George C. Harrison                              -----------------------
----- Professor of Computer Science                -----------------------
----- Norfolk State University                     -----------------------
----- 2401 Corprew Avenue, Norfolk, Virginia 23504 -----------------------
----- INTERNET:  g_harrison@vger.nsu.edu ---------------------------------

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

end of thread, other threads:[~1991-03-28 17:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-03-15 23:37 Immediate Reading in Tasks George C. Harrison, Norfolk State University
1991-03-19  3:19 ` William Loftus
1991-03-27 20:00 ` Use clauses in the visible parts of packages??? Scott Layson Burson
1991-03-28 17:17   ` Fred Stluka

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