diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-06 10:14:59 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-06 10:14:59 +0000 |
commit | 887e908c1fb2b02666239abd6e6253740ac934a7 (patch) | |
tree | 033a7e7bb81d1b4e3f0b917dd2668339fdc676b0 /gcc/ada/s-taprop-vms.adb | |
parent | df60170ddc5409cd057bef02d27df3806811d967 (diff) | |
download | gcc-887e908c1fb2b02666239abd6e6253740ac934a7.tar.gz |
2007-04-20 Arnaud Charlet <charlet@adacore.com>
* s-taprop-vms.adb, s-taprop-hpux-dce.adb, s-taprop-vxworks.adb,
s-osprim-posix.adb, s-taprop-posix.adb, s-osprim-vxworks.adb,
s-taprop-solaris.adb, s-osprim-solaris.adb, s-taprop-dummy.adb,
s-osprim-unix.adb, s-osinte-freebsd.adb, s-osinte-freebsd.ads,
s-osinte-lynxos.adb, s-osinte-lynxos.ads, s-taprop-tru64.adb,
s-taprop-lynxos.adb, s-taprop-irix.adb, s-osinte-tru64.adb,
s-osinte-tru64.ads, s-taprop-linux.adb, s-parame.ads,
s-parame-vms-alpha.ads, s-parame-vms-ia64.ads, s-parame-hpux.ads,
s-parame-vms-restrict.ads, s-parame-ae653.ads, s-parame-vxworks.ads,
s-taprop-mingw.adb, s-osinte-lynxos-3.ads, s-osinte-lynxos-3.adb,
s-osprim-mingw.adb (Timed_Delay, Timed_Sleep): Register the base
time when entering this routine to detect a backward clock setting
(manual setting or DST adjustment), to avoid waiting for a longer delay
than needed.
(Time_Duration, To_Timeval, struct_timeval): Removed when not relevant.
Remove handling of deferred priority change, and replace by setting the
task priority directly, as required by AI-188.
Update comments.
(Max_Task_Image_Length): New constant.
Replace Warnings (Off) by Unreferenced pragma, cleaner.
(Dynamic_Priority_Support): Removed, no longer needed.
(Poll_Base_Priority_Change): Ditto.
(Set_Ceiling): Add this procedure to change the ceiling priority
associated to a lock. This is a dummy implementation because dynamic
priority ceilings are not supported by the underlying system.
* a-dynpri.adb (Set_Priority): Take into account case where Target is
accepting a RV with its priority boosted.
Remove handling of deferred priority change, and replace by setting the
task priority directly, as required by AI-188.
* s-taenca.adb (Try_To_Cancel_Entry_Call): Remove special case for
Succeeded = True.
Remove handling of deferred priority change, and replace by setting the
task priority directly, as required by AI-188.
(Wait_For_Completion, Wait_For_Call, Timed_Selective_Wait): Change state
of Self_Id earlier.
* s-tasini.ads, s-tasini.adb (Wakeup_Entry_Caller): Relax assertion.
(Poll_Base_Priority_Change): Removed.
Code clean up: use SSL.Current_Target_Exception.
* s-tasren.adb (Task_Count): Call Yield to let a chance to other tasks
to run as this is a potentially dispatching point.
(Call_Synchronous): Use Local_Defer_Abort.
(Callable): Relax assertion.
(Selective_Wait): Relax assertion in case abort is not allowed.
Remove handling of deferred priority change, and replace by setting the
task priority directly, as required by AI-188.
* s-tasuti.adb (Make_Passive): Adjust assertions.
Remove handling of deferred priority change, and replace by setting the
task priority directly, as required by AI-188.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125364 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/s-taprop-vms.adb')
-rw-r--r-- | gcc/ada/s-taprop-vms.adb | 177 |
1 files changed, 106 insertions, 71 deletions
diff --git a/gcc/ada/s-taprop-vms.adb b/gcc/ada/s-taprop-vms.adb index f96534b45eb..5cade02b277 100644 --- a/gcc/ada/s-taprop-vms.adb +++ b/gcc/ada/s-taprop-vms.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -54,8 +54,8 @@ with System.Soft_Links; -- used for Get_Exc_Stack_Addr -- Abort_Defer/Undefer -with Unchecked_Conversion; -with Unchecked_Deallocation; +with Ada.Unchecked_Conversion; +with Ada.Unchecked_Deallocation; package body System.Task_Primitives.Operations is @@ -85,7 +85,7 @@ package body System.Task_Primitives.Operations is -- Key used to find the Ada Task_Id associated with a thread Environment_Task_Id : Task_Id; - -- A variable to hold Task_Id for the environment task. + -- A variable to hold Task_Id for the environment task Time_Slice_Val : Integer; pragma Import (C, Time_Slice_Val, "__gl_time_slice_val"); @@ -94,7 +94,7 @@ package body System.Task_Primitives.Operations is pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy"); Foreign_Task_Elaborated : aliased Boolean := True; - -- Used to identified fake tasks (i.e., non-Ada Threads). + -- Used to identified fake tasks (i.e., non-Ada Threads) -------------------- -- Local Packages -- @@ -104,7 +104,7 @@ package body System.Task_Primitives.Operations is procedure Initialize (Environment_Task : Task_Id); pragma Inline (Initialize); - -- Initialize various data needed by this package. + -- Initialize various data needed by this package function Is_Valid_Task return Boolean; pragma Inline (Is_Valid_Task); @@ -121,7 +121,7 @@ package body System.Task_Primitives.Operations is end Specific; package body Specific is separate; - -- The body of this package is target specific. + -- The body of this package is target specific --------------------------------- -- Support for foreign threads -- @@ -137,15 +137,17 @@ package body System.Task_Primitives.Operations is -- Local Subprograms -- ----------------------- - function To_Task_Id is new Unchecked_Conversion (System.Address, Task_Id); + function To_Task_Id is + new Ada.Unchecked_Conversion (System.Address, Task_Id); - function To_Address is new Unchecked_Conversion (Task_Id, System.Address); + function To_Address is + new Ada.Unchecked_Conversion (Task_Id, System.Address); function Get_Exc_Stack_Addr return Address; -- Replace System.Soft_Links.Get_Exc_Stack_Addr_NT procedure Timer_Sleep_AST (ID : Address); - -- Signal the condition variable when AST fires. + -- Signal the condition variable when AST fires procedure Timer_Sleep_AST (ID : Address) is Result : Interfaces.C.int; @@ -160,8 +162,8 @@ package body System.Task_Primitives.Operations is -- Stack_Guard -- ----------------- - -- The underlying thread system sets a guard page at the - -- bottom of a thread stack, so nothing is needed. + -- The underlying thread system sets a guard page at the bottom of a thread + -- stack, so nothing is needed. -- ??? Check the comment above procedure Stack_Guard (T : ST.Task_Id; On : Boolean) is @@ -190,15 +192,15 @@ package body System.Task_Primitives.Operations is -- Initialize_Lock -- --------------------- - -- Note: mutexes and cond_variables needed per-task basis are - -- initialized in Initialize_TCB and the Storage_Error is - -- handled. Other mutexes (such as RTS_Lock, Memory_Lock...) - -- used in RTS is initialized before any status change of RTS. - -- Therefore rasing Storage_Error in the following routines - -- should be able to be handled safely. + -- Note: mutexes and cond_variables needed per-task basis are initialized + -- in Initialize_TCB and the Storage_Error is handled. Other mutexes (such + -- as RTS_Lock, Memory_Lock...) used in RTS is initialized before any + -- status change of RTS. Therefore rasing Storage_Error in the following + -- routines should be able to be handled safely. procedure Initialize_Lock - (Prio : System.Any_Priority; L : not null access Lock) + (Prio : System.Any_Priority; + L : not null access Lock) is Attributes : aliased pthread_mutexattr_t; Result : Interfaces.C.int; @@ -226,7 +228,8 @@ package body System.Task_Primitives.Operations is end Initialize_Lock; procedure Initialize_Lock - (L : not null access RTS_Lock; Level : Lock_Level) + (L : not null access RTS_Lock; + Level : Lock_Level) is pragma Unreferenced (Level); @@ -289,7 +292,8 @@ package body System.Task_Primitives.Operations is ---------------- procedure Write_Lock - (L : not null access Lock; Ceiling_Violation : out Boolean) + (L : not null access Lock; + Ceiling_Violation : out Boolean) is Self_ID : constant Task_Id := Self; All_Tasks_Link : constant Task_Id := Self.Common.All_Tasks_Link; @@ -343,7 +347,9 @@ package body System.Task_Primitives.Operations is --------------- procedure Read_Lock - (L : not null access Lock; Ceiling_Violation : out Boolean) is + (L : not null access Lock; + Ceiling_Violation : out Boolean) + is begin Write_Lock (L, Ceiling_Violation); end Read_Lock; @@ -360,7 +366,8 @@ package body System.Task_Primitives.Operations is end Unlock; procedure Unlock - (L : not null access RTS_Lock; Global_Lock : Boolean := False) + (L : not null access RTS_Lock; + Global_Lock : Boolean := False) is Result : Interfaces.C.int; begin @@ -379,6 +386,21 @@ package body System.Task_Primitives.Operations is end if; end Unlock; + ----------------- + -- Set_Ceiling -- + ----------------- + + -- Dynamic priority ceilings are not supported by the underlying system + + procedure Set_Ceiling + (L : not null access Lock; + Prio : System.Any_Priority) + is + pragma Unreferenced (L, Prio); + begin + null; + end Set_Ceiling; + ----------- -- Sleep -- ----------- @@ -392,11 +414,13 @@ package body System.Task_Primitives.Operations is begin if Single_Lock then - Result := pthread_cond_wait - (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); + Result := + pthread_cond_wait + (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); else - Result := pthread_cond_wait - (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); + Result := + pthread_cond_wait + (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); end if; -- EINTR is not considered a failure @@ -437,9 +461,7 @@ package body System.Task_Primitives.Operations is Sleep_Time := To_OS_Time (Time, Mode); - if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level - or else Self_ID.Pending_Priority_Change - then + if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level then return; end if; @@ -454,13 +476,15 @@ package body System.Task_Primitives.Operations is end if; if Single_Lock then - Result := pthread_cond_wait - (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); + Result := + pthread_cond_wait + (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); pragma Assert (Result = 0); else - Result := pthread_cond_wait - (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); + Result := + pthread_cond_wait + (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); pragma Assert (Result = 0); end if; @@ -508,17 +532,13 @@ package body System.Task_Primitives.Operations is (Status, 0, Sleep_Time, Timer_Sleep_AST'Access, To_Address (Self_ID), 0); + -- Comment following test + if (Status and 1) /= 1 then raise Storage_Error; end if; loop - if Self_ID.Pending_Priority_Change then - Self_ID.Pending_Priority_Change := False; - Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority; - Set_Priority (Self_ID, Self_ID.Common.Base_Priority); - end if; - if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level then Sys_Cantim (Status, To_Address (Self_ID), 0); pragma Assert ((Status and 1) = 1); @@ -526,12 +546,16 @@ package body System.Task_Primitives.Operations is end if; if Single_Lock then - Result := pthread_cond_wait - (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); + Result := + pthread_cond_wait + (Self_ID.Common.LL.CV'Access, + Single_RTS_Lock'Access); pragma Assert (Result = 0); else - Result := pthread_cond_wait - (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); + Result := + pthread_cond_wait + (Self_ID.Common.LL.CV'Access, + Self_ID.Common.LL.L'Access); pragma Assert (Result = 0); end if; @@ -569,6 +593,7 @@ package body System.Task_Primitives.Operations is function RT_Resolution return Duration is begin + -- Document origin of this magic constant ??? return 10#1.0#E-3; end RT_Resolution; @@ -627,15 +652,17 @@ package body System.Task_Primitives.Operations is or else Priority_Specific_Policy = 'R' or else Time_Slice_Val > 0 then - Result := pthread_setschedparam - (T.Common.LL.Thread, SCHED_RR, Param'Access); + Result := + pthread_setschedparam + (T.Common.LL.Thread, SCHED_RR, Param'Access); elsif Dispatching_Policy = 'F' or else Priority_Specific_Policy = 'F' or else Time_Slice_Val = 0 then - Result := pthread_setschedparam - (T.Common.LL.Thread, SCHED_FIFO, Param'Access); + Result := + pthread_setschedparam + (T.Common.LL.Thread, SCHED_FIFO, Param'Access); else -- SCHED_OTHER priorities are restricted to the range 8 - 15. @@ -643,8 +670,9 @@ package body System.Task_Primitives.Operations is -- in a range of 16 - 31, dividing by 2 gives the correct result. Param.sched_priority := Param.sched_priority / 2; - Result := pthread_setschedparam - (T.Common.LL.Thread, SCHED_OTHER, Param'Access); + Result := + pthread_setschedparam + (T.Common.LL.Thread, SCHED_OTHER, Param'Access); end if; pragma Assert (Result = 0); @@ -727,8 +755,9 @@ package body System.Task_Primitives.Operations is pragma Assert (Result = 0 or else Result = ENOMEM); if Result = 0 then - Result := pthread_mutex_init (Self_ID.Common.LL.L'Access, - Mutex_Attr'Access); + Result := + pthread_mutex_init + (Self_ID.Common.LL.L'Access, Mutex_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); end if; @@ -745,8 +774,9 @@ package body System.Task_Primitives.Operations is pragma Assert (Result = 0 or else Result = ENOMEM); if Result = 0 then - Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, - Cond_Attr'Access); + Result := + pthread_cond_init + (Self_ID.Common.LL.CV'Access, Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); end if; @@ -791,7 +821,7 @@ package body System.Task_Primitives.Operations is Result : Interfaces.C.int; function Thread_Body_Access is new - Unchecked_Conversion (System.Address, Thread_Body); + Ada.Unchecked_Conversion (System.Address, Thread_Body); begin -- Since the initial signal mask of a thread is inherited from the @@ -822,13 +852,14 @@ package body System.Task_Primitives.Operations is (Attributes'Access, PTHREAD_EXPLICIT_SCHED); pragma Assert (Result = 0); - Result := pthread_create - (T.Common.LL.Thread'Access, - Attributes'Access, - Thread_Body_Access (Wrapper), - To_Address (T)); + Result := + pthread_create + (T.Common.LL.Thread'Access, + Attributes'Access, + Thread_Body_Access (Wrapper), + To_Address (T)); - -- ENOMEM is a valid run-time error. Don't shut down. + -- ENOMEM is a valid run-time error -- do not shut down pragma Assert (Result = 0 or else Result = EAGAIN or else Result = ENOMEM); @@ -853,9 +884,9 @@ package body System.Task_Primitives.Operations is Is_Self : constant Boolean := T = Self; procedure Free is new - Unchecked_Deallocation (Ada_Task_Control_Block, Task_Id); + Ada.Unchecked_Deallocation (Ada_Task_Control_Block, Task_Id); - procedure Free is new Unchecked_Deallocation + procedure Free is new Ada.Unchecked_Deallocation (Exc_Stack_T, Exc_Stack_Ptr_T); begin @@ -872,7 +903,6 @@ package body System.Task_Primitives.Operations is end if; Free (T.Common.LL.Exc_Stack_Ptr); - Free (Tmp); if Is_Self then @@ -911,8 +941,7 @@ package body System.Task_Primitives.Operations is Cond_Attr : aliased pthread_condattr_t; Result : Interfaces.C.int; begin - -- Initialize internal state. It is always initialized to False (ARM - -- D.10 par. 6). + -- Initialize internal state (always to False (D.10 (6))) S.State := False; S.Waiting := False; @@ -977,7 +1006,8 @@ package body System.Task_Primitives.Operations is -------------- procedure Finalize (S : in out Suspension_Object) is - Result : Interfaces.C.int; + Result : Interfaces.C.int; + begin -- Destroy internal mutex @@ -1007,7 +1037,8 @@ package body System.Task_Primitives.Operations is --------------- procedure Set_False (S : in out Suspension_Object) is - Result : Interfaces.C.int; + Result : Interfaces.C.int; + begin SSL.Abort_Defer.all; @@ -1028,6 +1059,7 @@ package body System.Task_Primitives.Operations is procedure Set_True (S : in out Suspension_Object) is Result : Interfaces.C.int; + begin SSL.Abort_Defer.all; @@ -1036,8 +1068,7 @@ package body System.Task_Primitives.Operations is -- If there is already a task waiting on this suspension object then -- we resume it, leaving the state of the suspension object to False, - -- as it is specified in ARM D.10 par. 9. Otherwise, it just leaves - -- the state to True. + -- as specified in (RM D.10(9)), otherwise leave state set to True. if S.Waiting then S.Waiting := False; @@ -1045,6 +1076,7 @@ package body System.Task_Primitives.Operations is Result := pthread_cond_signal (S.CV'Access); pragma Assert (Result = 0); + else S.State := True; end if; @@ -1061,6 +1093,7 @@ package body System.Task_Primitives.Operations is procedure Suspend_Until_True (S : in out Suspension_Object) is Result : Interfaces.C.int; + begin SSL.Abort_Defer.all; @@ -1068,9 +1101,10 @@ package body System.Task_Primitives.Operations is pragma Assert (Result = 0); if S.Waiting then + -- Program_Error must be raised upon calling Suspend_Until_True -- if another task is already waiting on that suspension object - -- (ARM D.10 par. 10). + -- (RM D.10(10)). Result := pthread_mutex_unlock (S.L'Access); pragma Assert (Result = 0); @@ -1078,6 +1112,7 @@ package body System.Task_Primitives.Operations is SSL.Abort_Undefer.all; raise Program_Error; + else -- Suspend the task if the state is False. Otherwise, the task -- continues its execution, and the state of the suspension object |