CVS difference for ais/ai-10266.txt

Differences between 1.17 and version 1.18
Log of other versions for file ais/ai-10266.txt

--- ais/ai-10266.txt	2005/03/22 02:10:37	1.17
+++ ais/ai-10266.txt	2005/03/22 03:16:11	1.18
@@ -1,4 +1,4 @@
-!standard C.7.3 (01)                                05-03-07  AI95-00266-02/09
+!standard C.7.3 (01)                                05-03-21  AI95-00266-02/10
 !standard C.7 (00)
 !standard C.7 (01)
 !class amendment 01-06-01
@@ -41,12 +41,8 @@
 
 Add new section C.7.3
 
-Task Termination Procedures
+The Package Task_Termination
 
-This clause specifies a package for associating protected procedures
-with a task. One such procedure is invoked when the task is about to
-terminate.
-
 Static Semantics
 
 The following language-defined library package exists:
@@ -55,63 +51,81 @@
 with Ada.Task_Identification;
 with Ada.Exceptions;
 package Ada.Task_Termination is
+  pragma Preelaborate (Task_Termination);
 
   type Cause_Of_Termination is (Normal, Abnormal, Unhandled_Exception);
 
-  type Termination_Handler is access protected procedure(
-      Cause : in Cause_Of_Termination;
-      T : in Ada.Task_Identification.Task_Id;
-      X : in Ada.Exceptions.Exception_Occurrence);
+  type Termination_Handler is access protected procedure
+    (Cause : in Cause_Of_Termination;
+     T     : in Ada.Task_Identification.Task_Id;
+     X     : in Ada.Exceptions.Exception_Occurrence);
 
-  procedure Set_Dependents_Fallback_Handler(
-      Handler: in Termination_Handler);
+  procedure Set_Dependents_Fallback_Handler
+    (Handler: in Termination_Handler);
   function Current_Task_Fallback_Handler return Termination_Handler;
 
-  procedure Set_Specific_Handler(T : in Ada.Task_Identification.Task_Id;
-                        Handler : in Termination_Handler);
-  function Specific_Handler(T : Ada.Task_Identification.Task_Id)
+  procedure Set_Specific_Handler
+    (T       : in Ada.Task_Identification.Task_Id;
+     Handler : in Termination_Handler);
+  function Specific_Handler (T : Ada.Task_Identification.Task_Id)
       return Termination_Handler;
 
 end Ada.Task_Termination;
 
 Dynamic Semantics
+
+The type Termination_Handler identifies a protected procedure to be executed by
+the implementation when a task terminates. Such a protected procedure is called
+a *handler*. In all cases T identifies the task that is terminating. If the
+task terminates due to completing the last statement of its body, or as a
+result of waiting on a terminate alternative, then Cause is set to Normal and X
+is set to Null_Occurrence. If the task terminates because it is being aborted,
+then Cause is set to Abnormal and X is set to Null_Occurrence. If the task
+terminates because of an exception raised by the execution of its task_body,
+then Cause is set to Unhandled_Exception and X is set to the associated
+exception occurrence.
+
+Each task has two termination handlers, a *fall-back handler* and a *specific
+handler*. A handler is said to be *set* if it is associated with a non-null
+value of type Termination_Handler, and *cleared* otherwise. When a task is
+created, its specific handler and fall-back handler are cleared.
+
+The procedure Set_Dependents_Fallback_Handler changes the fall-back handler for
+the calling task; if Handler is null,
+that fall-back handler is cleared, otherwise it is set to be Handler.all.
+If a fall-back handler had previously been set it is replaced.
+
+The function Current_Task_Fallback_Handler returns the fall-back handler that
+is currently set for the calling task, if one is set; otherwise it returns
+null.
+
+The procedure Set_Specific_Handler changes the specific handler for the task
+identified by T; if Handler is null, that specific handler is cleared,
+otherwise it is set to be Handler.all. If a specific handler had previously
+been set it is replaced.
 
-A call of Set_Dependents_Fallback_Handler sets the fall-back handler
-for all dependent tasks. If a fall-back handler had previously been
-set it is replaced. A call with a null access parameter is
-equivalent to removing the fall-back handler. A call of
-Current_Task_Fallback_Handler returns the fall-back handler that is currently
-in effect for the calling task. If no fall-back handler has been set
-it returns null.
-
-A call of Set_Specific_Handler sets a specific handler for the
-task identified by T. If a specific handler had previously been set
-it is replaced. A call with a null access parameter is equivalent
-to removing the specific handler. A call of Specific_Handler returns
-the specific handler if one has been set, otherwise it returns null.
+The function Specific_Handler returns the specific handler that is currently
+set for the task identified by T, if one is set; otherwise it returns null.
 
 As part of the finalization of a task_body, after performing the actions
-specified in 7.6 for finalization of a master, the task specific handler,
-if not @b<null>, is called. If there is no such specific handler, a fall-back
-handler is determined by recursively searching for a non-null fall-back
-handler in the tasks upon which it depends. If such a fall-back handler
-is determined it is executed; otherwise no handler is executed.
-
-If the task completed due to completing the last statement
-of the task body, or as a result of waiting on a terminate
-alternative then Cause is set to Normal and X is set to Null_Occurrence.
-If completion is due to abort then Cause is set
-to Abnormal and X is set to Null_Occurrence. If completion is
-due to an unhandled exception then Cause is set to Unhandled_Exception
-and X is set to the associated exception occurrence.
+specified in 7.6 for finalization of a master, the specific handler for the
+task, if one is set, is executed. If the specific handler is cleared, a search
+for a fall-back handler proceeds by recursively following the master
+relationship for the task. If a task is found whose fall-back handler is set,
+that handler is executed; otherwise, no handler is executed.
 
-For all the operations defined in this package, Tasking_Error
+For Set_Specific_Handler or Specific_Handler, Tasking_Error
 is raised if the task identified by T has already terminated. Program_Error
-is raised if the value of T is Null_Task_ID.
+is raised if the value of T is Ada.Task_Identification.Null_Task_Id.
 
 An exception propagated from a handler that is invoked as part of
 the termination of a task has no effect.
 
+Erroneous Execution
+
+For a call of Set_Specific_Handler or Specific_Handler, if the task identified
+by T no longer exists, the execution of the program is erroneous.
+
 !discussion
 
 Many safety critical and high integrity systems prohibit (or discourage)
@@ -243,77 +257,89 @@
 
 @dinsc
 
-This clause specifies a package for associating protected procedures
-with a task. One such procedure is invoked when the task is about to
-terminate.
-
 @i<@s8<Static Semantics>>
 
 The following language-defined library package exists:
 
-@xcode<@b<with> System;
-@b<with> Ada.Task_Identification;
+@xcode<@b<with> Ada.Task_Identification;
 @b<with> Ada.Exceptions;
 @b<package> Ada.Task_Termination @b<is>
+   @b<pragma> Preelaborate (Task_Termination);
 
    @b<type> Cause_Of_Termination @b<is> (Normal, Abnormal, Unhandled_Exception);
 
-   @b<type> Termination_Handler @b<is access protected procedure>(
-      Cause : @b<in> Cause_Of_Termination;
+   @b<type> Termination_Handler @b<is access protected procedure>
+     (Cause : @b<in> Cause_Of_Termination;
       T     : @b<in> Ada.Task_Identification.Task_Id;
       X     : @b<in> Ada.Exceptions.Exception_Occurrence);
 
-   @b<procedure> Set_Dependents_Fallback_Handler(
-      Handler: @b<in> Termination_Handler);
+   @b<procedure> Set_Dependents_Fallback_Handler
+     (Handler: @b<in> Termination_Handler);
    @b<function> Current_Task_Fallback_Handler return Termination_Handler;
 
-   @b<procedure> Set_Specific_Handler(
-      T           : @b<in> Ada.Task_Identification.Task_Id;
-      Handler     : @b<in> Termination_Handler);
-   @b<function> Specific_Handler(T : Ada.Task_Identification.Task_Id)
+   @b<procedure> Set_Specific_Handler
+     (T       : @b<in> Ada.Task_Identification.Task_Id;
+      Handler : @b<in> Termination_Handler);
+   @b<function> Specific_Handler (T : Ada.Task_Identification.Task_Id)
       @b<return> Termination_Handler;
 
 @b<end> Ada.Task_Termination;>
 
 @i<@s8<Dynamic Semantics>>
+
+The type Termination_Handler identifies a protected procedure to be executed by
+the implementation when a task terminates. Such a protected procedure is called
+a @i<handler>. In all cases T identifies the task that is terminating. If the
+task terminates due to completing the last statement of its body, or as a
+result of waiting on a terminate alternative, then Cause is set to Normal and X
+is set to Null_Occurrence. If the task terminates because it is being aborted,
+then Cause is set to Abnormal and X is set to Null_Occurrence. If the task
+terminates because of an exception raised by the execution of its
+@fa<task_body>, then Cause is set to Unhandled_Exception and X is set to the
+associated exception occurrence.
+
+Each task has two termination handlers, a @i<fall-back handler> and a
+@i<specific handler>. The specific handler applies only to the task itself,
+while the fall-back handler applies only to the dependent tasks of the task.
+A handler is said to be @i<set> if it is associated
+with a non-null value of type Termination_Handler, and @i<cleared> otherwise.
+When a task is created, its specific handler and fall-back handler are cleared.
+
+The procedure Set_Dependents_Fallback_Handler changes the fall-back handler for
+the calling task; if Handler is @b<null>,
+that fall-back handler is cleared, otherwise it is set to be Handler.@b<all>.
+If a fall-back handler had previously been set it is replaced.
+
+The function Current_Task_Fallback_Handler returns the fall-back handler that
+is currently set for the calling task, if one is set; otherwise it returns
+@b<null>.
+
+The procedure Set_Specific_Handler changes the specific handler for the task
+identified by T; if Handler is @b<null>, that specific handler is cleared,
+otherwise it is set to be Handler.@b<all>. If a specific handler had previously
+been set it is replaced.
 
-A call of Set_Dependents_Fallback_Handler sets the @i<fall-back handler>
-for all dependent tasks. If a fall-back handler had previously been
-set it is replaced. A call with a null access parameter is
-equivalent to removing the fall-back handler. A call of
-Current_Task_Fallback_Handler returns the fall-back handler that is currently
-in effect for the calling task. If no fall-back handler has been set
-it returns @b<null>.
-
-A call of Set_Specific_Handler sets a specific handler for the
-task identified by T. If a specific handler had previously been set
-it is replaced. A call with a null access parameter is equivalent
-to removing the specific handler. A call of Specific_Handler returns
-the specific handler if one has been set, otherwise the handler it
-returns @b<null>.
+The function Specific_Handler returns the specific handler that is currently
+set for the task identified by T, if one is set; otherwise it returns @b<null>.
 
 As part of the finalization of a @fa<task_body>, after performing the actions
-specified in 7.6 for finalization of a master, the task specific handler,
-if not null, is called. If there is no such specific handler, a fall-back
-handler is determined by recursively searching for a non-null fall-back
-handler in the tasks upon which it depends. If such a fall-back handler
-is determined it is executed; otherwise no handler is executed.
-
-If the task completed due to completing the last statement
-of the task body, or as a result of waiting on a terminate
-alternative then Cause is set to Normal and X is set to Null_Occurrence.
-If completion is due to abort then Cause is set
-to Abnormal and X is set to Null_Occurrence. If completion is
-due to an unhandled exception then Cause is set to Unhandled_Exception
-and X is set to the associated exception occurrence.
+specified in 7.6 for finalization of a master, the specific handler for the
+task, if one is set, is executed. If the specific handler is cleared, a search
+for a fall-back handler proceeds by recursively following the master
+relationship for the task. If a task is found whose fall-back handler is set,
+that handler is executed; otherwise, no handler is executed.
 
-For all the operations defined in this package, Tasking_Error
+For Set_Specific_Handler or Specific_Handler, Tasking_Error
 is raised if the task identified by T has already terminated. Program_Error
-is raised if the value of T is Null_Task_ID.
+is raised if the value of T is Ada.Task_Identification.Null_Task_ID.
 
 An exception propagated from a handler that is invoked as part of
 the termination of a task has no effect.
 
+@i<@s8<Erroneous Execution>>
+
+For a call of Set_Specific_Handler or Specific_Handler, if the task identified
+by T no longer exists, the execution of the program is erroneous.
 !ACATS test
 
 ACATS test(s) need to be constructed for this feature.

Questions? Ask the ACAA Technical Agent