comp.lang.ada
 help / color / mirror / Atom feed
* Asynchronous entry call proposal
@ 1989-04-20 17:20 stt
  1989-04-22 15:59 ` William Thomas Wolfe,2847,
  0 siblings, 1 reply; 3+ messages in thread
From: stt @ 1989-04-20 17:20 UTC (permalink / raw)



The recent International Workshop on Real-Time Ada Issues
debated various alternatives for providing
asynchronous transfer of control in Ada.

Here is a new proposal using entry calls
rather than exceptions to provide the asynchronous
transfer of control.  This proposal has also been submitted
to the Ada9X revision-request mailbox.
---------

To satisfy perceived requirements for asynchronous transfer
of control [Ada letters special edition, Vol VII,7 Fall 88 --
2nd Int'l Wkshp on RT Ada Issues -- hereafter IWRT2], we propose the provision
for an asynchronous entry call/selective wait construct.

There are many situations where it is useful to terminate
one sort of processing and continue processing in
a new place, based on an external/terminal interrupt, mode switch,
etc.   Currently interrupts may be bound to task entries, but
there is no action which can be taken within the
corresponding accept body to terminate ongoing
processing other than the abort statement.  
It was felt by most of the participants of [IWRT2] that
this approach was unacceptably expensive and inadequately
controllable.  

The approach most widely recommended
in [IWRT2] was asynchronous exceptions.  However, many
problems were identified with this approach, requiring
an number of new concepts such as enabling/disabling exceptions,
new classes of exceptions, queuing rules, etc.  We feel
that an asynchronous entry call/selective wait construct solves
many of these problems while introducing fewer new
concepts into the language.

Here is the proposed new selective wait construct:

select
   select_alternative
{ or 
    select_alternative}
and
   sequence_of_statements
end select;

The semantics of this construct are that
normal processing is performed on the select alternative guards
to determine which should be "open."  Selection of one such
open alternative takes place immediately if a rendezvous is
possible, or if a delay alternative of less than or equal to zero seconds
is open.  Otherwise, the sequence_of_statements begin execution.
If the sequence_of_statements completes execution,
then the select alternatives are closed.

If prior to completion of the sequence_of_statements and outside of
any nested rendezvous (either accept or entry call),
a delay alternative has expired, or an open accept alternative has a caller,
then the sequence_of_statements is abandoned, 
and an asynchronous transfer
of control takes place to the appropriate open select alternative.
This abandonment takes place no later than the next synchronization
point, but it is the intent that any ongoing computation 
(outside of a rendezvous) be preempted.

If the same entry is made open via a nested selective wait
or accept statement, then the inner construct takes precedence.

Nested rendezvous are protected from preemption to
prevent corruption of protected data structures and
undesirable side effects in the calling task.
Note however, that within a nested accept it is
possible to further nest an asynchronous selective wait
thereby again allowing for nested asynchronous transfer of control.

Here are some examples of use:

    loop -- Main command loop for a command interpreter
        select
            accept Terminal_Interrupt;
	    Put_Line("Interrupted");
        and
	    -- This will be abandoned upon terminal interrupt
	    Put_Line("-> ");
	    Get_Line(Command, Last);
	    Process_Command(Command(1..Last));
        end select;
    end loop;

---------------------------
    select  -- Perform time-limited calculation
	delay 5.0;
	Put_Line("Calculation does not converge");
    and
	-- This calculation should finish in 5.0 seconds
        -- if not, it is assumed to diverge
        Horribly_Complicated_Recursive_Function(X, Y);
    end select;

------------------------------

    S. Tucker Taft
    Intermetrics, Inc.
    733 Concord Avenue
    Cambridge, MA  02138
    617-661-1840
    stt@inmet.inmet.com / uunet!inmet!stt

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

end of thread, other threads:[~1989-05-04 21:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1989-04-20 17:20 Asynchronous entry call proposal stt
1989-04-22 15:59 ` William Thomas Wolfe,2847,
1989-05-04 21:05   ` Tucker Taft

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