OSDN Git Service

optimize
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-taskin.ads
index 04a7657..8e5616b 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                  S p e c                                 --
 --                                                                          --
---          Copyright (C) 1992-2003, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2004, 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- --
@@ -55,21 +55,21 @@ with Unchecked_Conversion;
 
 package System.Tasking is
 
-   --  -------------------
-   --  -- Locking Rules --
-   --  -------------------
-   --
+   -------------------
+   -- Locking Rules --
+   -------------------
+
    --  The following rules must be followed at all times, to prevent
    --  deadlock and generally ensure correct operation of locking.
-   --
+
    --  . Never lock a lock unless abort is deferred.
-   --
+
    --  . Never undefer abort while holding a lock.
-   --
+
    --  . Overlapping critical sections must be properly nested,
    --    and locks must be released in LIFO order.
    --    e.g., the following is not allowed:
-   --
+
    --         Lock (X);
    --         ...
    --         Lock (Y);
@@ -77,31 +77,31 @@ package System.Tasking is
    --         Unlock (X);
    --         ...
    --         Unlock (Y);
-   --
+
    --  Locks with lower (smaller) level number cannot be locked
    --  while holding a lock with a higher level number. (The level
    --  number is the number at the left.)
-   --
+
    --  1. System.Tasking.PO_Simple.Protection.L (any PO lock)
    --  2. System.Tasking.Initialization.Global_Task_Lock (in body)
    --  3. System.Task_Primitives.Operations.Single_RTS_Lock
    --  4. System.Tasking.Ada_Task_Control_Block.LL.L (any TCB lock)
-   --
+
    --  Clearly, there can be no circular chain of hold-and-wait
    --  relationships involving locks in different ordering levels.
-   --
+
    --  We used to have Global_Task_Lock before Protection.L but this was
    --  clearly wrong since there can be calls to "new" inside protected
    --  operations. The new ordering prevents these failures.
-   --
+
    --  Sometimes we need to hold two ATCB locks at the same time. To allow
    --  us to order the locking, each ATCB is given a unique serial
    --  number. If one needs to hold locks on several ATCBs at once,
    --  the locks with lower serial numbers must be locked first.
-   --
+
    --  We don't always need to check the serial numbers, since
    --  the serial numbers are assigned sequentially, and so:
-   --
+
    --  . The parent of a task always has a lower serial number.
    --  . The activator of a task always has a lower serial number.
    --  . The environment task has a lower serial number than any other task.
@@ -109,24 +109,24 @@ package System.Tasking is
    --    the parent always has a lower serial number than the activator.
 
    ---------------------------------
-   -- Task_ID related definitions --
+   -- Task_Id related definitions --
    ---------------------------------
 
    type Ada_Task_Control_Block;
 
-   type Task_ID is access all Ada_Task_Control_Block;
+   type Task_Id is access all Ada_Task_Control_Block;
 
-   Null_Task : constant Task_ID;
+   Null_Task : constant Task_Id;
 
-   type Task_List is array (Positive range <>) of Task_ID;
+   type Task_List is array (Positive range <>) of Task_Id;
 
-   function Self return Task_ID;
+   function Self return Task_Id;
    pragma Inline (Self);
    --  This is the compiler interface version of this function. Do not call
    --  from the run-time system.
 
-   function To_Task_Id is new Unchecked_Conversion (System.Address, Task_ID);
-   function To_Address is new Unchecked_Conversion (Task_ID, System.Address);
+   function To_Task_Id is new Unchecked_Conversion (System.Address, Task_Id);
+   function To_Address is new Unchecked_Conversion (Task_Id, System.Address);
 
    -----------------------
    -- Enumeration types --
@@ -301,7 +301,7 @@ package System.Tasking is
    --      async. select statement does not need to lock anything.
 
    type Restricted_Entry_Call_Record is record
-      Self : Task_ID;
+      Self : Task_Id;
       --  ID of the caller
 
       Mode : Call_Modes;
@@ -360,25 +360,24 @@ package System.Tasking is
    --  Some protection is described in terms of tasks related to the
    --  ATCB being protected. These are:
 
-   --    Self: The task which is controlled by this ATCB.
-   --    Acceptor: A task accepting a call from Self.
-   --    Caller: A task calling an entry of Self.
-   --    Parent: The task executing the master on which Self depends.
-   --    Dependent: A task dependent on Self.
-   --    Activator: The task that created Self and initiated its activation.
-   --    Created: A task created and activated by Self.
+   --    Self:      The task which is controlled by this ATCB
+   --    Acceptor:  A task accepting a call from Self
+   --    Caller:    A task calling an entry of Self
+   --    Parent:    The task executing the master on which Self depends
+   --    Dependent: A task dependent on Self
+   --    Activator: The task that created Self and initiated its activation
+   --    Created:   A task created and activated by Self
 
    --  Note: The order of the fields is important to implement efficiently
    --  tasking support under gdb.
    --  Currently gdb relies on the order of the State, Parent, Base_Priority,
    --  Task_Image, Task_Image_Len, Call and LL fields.
 
-   ----------------------------------------------------------------------
-   --  Common ATCB section                                             --
-   --                                                                  --
-   --  This section is used by all GNARL implementations (regular and  --
-   --  restricted)                                                     --
-   ----------------------------------------------------------------------
+   -------------------------
+   -- Common ATCB section --
+   -------------------------
+
+   --  Section used by all GNARL implementations (regular and restricted)
 
    type Common_ATCB is record
       State : Task_States;
@@ -388,7 +387,7 @@ package System.Tasking is
       --  and whether it is terminated.
       --  Protection: Self.L.
 
-      Parent : Task_ID;
+      Parent : Task_Id;
       --  The task on which this task depends.
       --  See also Master_Level and Master_Within.
 
@@ -461,15 +460,15 @@ package System.Tasking is
       --  per-task structures.
       --  Protection: Only accessed by Self.
 
-      All_Tasks_Link : Task_ID;
+      All_Tasks_Link : Task_Id;
       --  Used to link this task to the list of all tasks in the system.
       --  Protection: RTS_Lock.
 
-      Activation_Link : Task_ID;
+      Activation_Link : Task_Id;
       --  Used to link this task to a list of tasks to be activated.
       --  Protection: Only used by Activator.
 
-      Activator : Task_ID;
+      Activator : Task_Id;
       --  The task that created this task, either by declaring it as a task
       --  object or by executing a task allocator.
       --  The value is null iff Self has completed activation.
@@ -542,16 +541,16 @@ package System.Tasking is
    end record;
    pragma Suppress_Initialization (Restricted_Ada_Task_Control_Block);
 
-   Interrupt_Manager_ID : Task_ID;
+   Interrupt_Manager_ID : Task_Id;
    --  This task ID is declared here to break circular dependencies.
-   --  Also declare Interrupt_Manager_ID after Task_ID is known, to avoid
+   --  Also declare Interrupt_Manager_ID after Task_Id is known, to avoid
    --  generating unneeded finalization code.
 
    -----------------------
    -- List of all Tasks --
    -----------------------
 
-   All_Tasks_List : Task_ID;
+   All_Tasks_List : Task_Id;
    --  Global linked list of all tasks.
 
    ------------------------------------------
@@ -633,7 +632,7 @@ package System.Tasking is
    ----------------------------------
 
    type Entry_Call_Record is record
-      Self  : Task_ID;
+      Self  : Task_Id;
       --  ID of the caller
 
       Mode : Call_Modes;
@@ -679,7 +678,7 @@ package System.Tasking is
       --  They are gathered together to allow for compilers that lay records
       --  out contiguously, to allow for such packing.
 
-      Called_Task : Task_ID;
+      Called_Task : Task_Id;
       pragma Atomic (Called_Task);
       --  Use for task entry calls.
       --  The value is null if the call record is not in use.
@@ -728,6 +727,12 @@ package System.Tasking is
    ------------------------------------
 
    type Access_Address is access all System.Address;
+   --  Comment on what this is used for ???
+
+   pragma No_Strict_Aliasing (Access_Address);
+   --  This type is used in contexts where aliasing may be an issue (see
+   --  for example s-tataat.adb), so we avoid any incorrect aliasing
+   --  assumptions.
 
    ----------------------------------------------
    -- Ada_Task_Control_Block (ATCB) definition --
@@ -947,25 +952,25 @@ package System.Tasking is
    ---------------------
 
    procedure Initialize_ATCB
-     (Self_ID          : Task_ID;
+     (Self_ID          : Task_Id;
       Task_Entry_Point : Task_Procedure_Access;
       Task_Arg         : System.Address;
-      Parent           : Task_ID;
+      Parent           : Task_Id;
       Elaborated       : Access_Boolean;
       Base_Priority    : System.Any_Priority;
       Task_Info        : System.Task_Info.Task_Info_Type;
       Stack_Size       : System.Parameters.Size_Type;
-      T                : in out Task_ID;
+      T                : in out Task_Id;
       Success          : out Boolean);
    --  Initialize fields of a TCB and link into global TCB structures
    --  Call this only with abort deferred and holding RTS_Lock.
 
 private
 
-   Null_Task : constant Task_ID := null;
+   Null_Task : constant Task_Id := null;
 
    type Activation_Chain is record
-      T_ID : Task_ID;
+      T_ID : Task_Id;
    end record;
    pragma Volatile (Activation_Chain);