+
+ -- Look for a fall-back handler. It can be either in the task itself
+ -- or in the environment task. Note that this code is always executed
+ -- by a task whose master is the environment task. The task termination
+ -- code for the environment task is executed by
+ -- SSL.Task_Termination_Handler.
+
+ -- This package is part of the restricted run time which supports
+ -- neither task hierarchies (No_Task_Hierarchy) nor specific task
+ -- termination handlers (No_Specific_Termination_Handlers).
+
+ -- There is no need for explicit protection against race conditions
+ -- for Self_ID.Common.Fall_Back_Handler because this procedure can
+ -- only be executed by Self, and the Fall_Back_Handler can only be
+ -- modified by Self.
+
+ if Self_ID.Common.Fall_Back_Handler /= null then
+ Self_ID.Common.Fall_Back_Handler (Cause, Self_ID, EO);
+ else
+ declare
+ TH : Termination_Handler := null;
+
+ begin
+ if Single_Lock then
+ Lock_RTS;
+ end if;
+
+ Write_Lock (Self_ID.Common.Parent);
+
+ TH := Self_ID.Common.Parent.Common.Fall_Back_Handler;
+
+ Unlock (Self_ID.Common.Parent);
+
+ if Single_Lock then
+ Unlock_RTS;
+ end if;
+
+ -- Execute the task termination handler if we found it
+
+ if TH /= null then
+ TH.all (Cause, Self_ID, EO);
+ end if;
+ end;
+ end if;
+
+ Terminate_Task (Self_ID);