diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-02-15 09:28:13 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-02-15 09:28:13 +0000 |
commit | 2e70d70dab8bc2f09b71041dc9719a5fbed638ab (patch) | |
tree | ff0fc56323a0b3142eb004ad33e55efe4c4a9b4e /gcc/ada/a-taster.adb | |
parent | 781d92c8873c51c988ccca82594906894fd0cd80 (diff) | |
download | gcc-2e70d70dab8bc2f09b71041dc9719a5fbed638ab.tar.gz |
2006-02-13 Jose Ruiz <ruiz@adacore.com>
* a-taster.adb (Current_Task_Fallback_Handler): Document why explicit
protection against race conditions is not needed.
(Set_Dependents_Fallback_Handler): Add mutual exclusive access to the
fallback handler.
(Set_Specific_Handler): Add mutual exclusive access to the specific
handler.
(Specific_Handler): Add mutual exclusive access for retrieving the
specific handler.
* s-tarest.adb (Task_Wrapper): Add mutual exclusive access to the fall
back handler.
* s-taskin.ads (Common_ATCB): Remove pragma Atomic for
Fall_Back_Handler and Specific_Handler.
* s-tassta.adb (Task_Wrapper): Add mutual exclusive access to the task
termination handlers.
Set two different owerflow depending on the maximal stack size.
* s-solita.adb (Task_Termination_Handler_T): Document why explicit
protection against race conditions is not needed when executing the
task termination handler.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111022 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-taster.adb')
-rw-r--r-- | gcc/ada/a-taster.adb | 91 |
1 files changed, 86 insertions, 5 deletions
diff --git a/gcc/ada/a-taster.adb b/gcc/ada/a-taster.adb index 93374b269a3..8b0be0a22f6 100644 --- a/gcc/ada/a-taster.adb +++ b/gcc/ada/a-taster.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2005, Free Software Foundation, Inc. -- +-- Copyright (C) 2005-2006, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- @@ -40,6 +40,17 @@ with System.Tasking; with System.Task_Primitives.Operations; -- used for Self +-- Write_Lock +-- Unlock +-- Lock_RTS +-- Unlock_RTS + +with System.Parameters; +-- used for Single_Lock + +with System.Soft_Links; +-- use for Abort_Defer +-- Abort_Undefer with Unchecked_Conversion; @@ -48,6 +59,9 @@ package body Ada.Task_Termination is use type Ada.Task_Identification.Task_Id; package STPO renames System.Task_Primitives.Operations; + package SSL renames System.Soft_Links; + + use System.Parameters; ----------------------- -- Local subprograms -- @@ -68,7 +82,11 @@ package body Ada.Task_Termination is function Current_Task_Fallback_Handler return Termination_Handler is begin - return To_TT (System.Tasking.Self.Common.Fall_Back_Handler); + -- There is no need for explicit protection against race conditions + -- for this function because this function can only be executed by + -- Self, and the Fall_Back_Handler can only be modified by Self. + + return To_TT (STPO.Self.Common.Fall_Back_Handler); end Current_Task_Fallback_Handler; ------------------------------------- @@ -78,8 +96,26 @@ package body Ada.Task_Termination is procedure Set_Dependents_Fallback_Handler (Handler : Termination_Handler) is + Self : constant System.Tasking.Task_Id := STPO.Self; + begin - STPO.Self.Common.Fall_Back_Handler := To_ST (Handler); + SSL.Abort_Defer.all; + + if Single_Lock then + STPO.Lock_RTS; + end if; + + STPO.Write_Lock (Self); + + Self.Common.Fall_Back_Handler := To_ST (Handler); + + STPO.Unlock (Self); + + if Single_Lock then + STPO.Unlock_RTS; + end if; + + SSL.Abort_Undefer.all; end Set_Dependents_Fallback_Handler; -------------------------- @@ -100,7 +136,28 @@ package body Ada.Task_Termination is elsif Ada.Task_Identification.Is_Terminated (T) then raise Tasking_Error; else - To_Task_Id (T).Common.Specific_Handler := To_ST (Handler); + declare + Target : constant System.Tasking.Task_Id := To_Task_Id (T); + + begin + SSL.Abort_Defer.all; + + if Single_Lock then + STPO.Lock_RTS; + end if; + + STPO.Write_Lock (Target); + + Target.Common.Specific_Handler := To_ST (Handler); + + STPO.Unlock (Target); + + if Single_Lock then + STPO.Unlock_RTS; + end if; + + SSL.Abort_Undefer.all; + end; end if; end Set_Specific_Handler; @@ -121,7 +178,31 @@ package body Ada.Task_Termination is elsif Ada.Task_Identification.Is_Terminated (T) then raise Tasking_Error; else - return To_TT (To_Task_Id (T).Common.Specific_Handler); + declare + Target : constant System.Tasking.Task_Id := To_Task_Id (T); + TH : Termination_Handler; + + begin + SSL.Abort_Defer.all; + + if Single_Lock then + STPO.Lock_RTS; + end if; + + STPO.Write_Lock (Target); + + TH := To_TT (Target.Common.Specific_Handler); + + STPO.Unlock (Target); + + if Single_Lock then + STPO.Unlock_RTS; + end if; + + SSL.Abort_Undefer.all; + + return TH; + end; end if; end Specific_Handler; |