From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!bbn!inmet!ishmael!inmet!stt From: stt@inmet Newsgroups: comp.lang.ada Subject: Asynchronous entry call proposal Message-ID: <124000037@inmet> Date: 20 Apr 89 17:20:00 GMT Nf-ID: #N:inmet:124000037:000:3943 Nf-From: inmet!stt Apr 20 13:20:00 1989 List-Id: 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