2006-10-31 Javier Miranda <miranda@adacore.com>
authorJavier Miranda <miranda@adacore.com>
Tue, 31 Oct 2006 18:11:44 +0000 (19:11 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 31 Oct 2006 18:11:44 +0000 (19:11 +0100)
* s-tpoben.ads, s-tpoben.adb, s-taprob.ads, s-taprob.adb
(Get_Ceiling): New subprogram that returns
the ceiling priority of the protected object.
(Set_Ceiling): New subprogram that sets the new ceiling priority of
the protected object.

* s-tarest.adb: (Create_Restricted_Task): Fix potential CE.

* s-taskin.ads, s-taskin.adb: (Storage_Size): New function.

From-SVN: r118317

gcc/ada/s-taprob.adb
gcc/ada/s-taprob.ads
gcc/ada/s-tarest.adb
gcc/ada/s-taskin.adb
gcc/ada/s-taskin.ads
gcc/ada/s-tpoben.adb
gcc/ada/s-tpoben.ads

index cd762c7ec5bb07b10757ae14b0a11cbbc9cb01c9..d4b08e4c1f170ae2fe4e23e31232b3219eadf34a 100644 (file)
@@ -7,7 +7,7 @@
 --                                  B o d y                                 --
 --                                                                          --
 --             Copyright (C) 1991-1994, Florida State University            --
---                     Copyright (C) 1995-2005, AdaCore                     --
+--                     Copyright (C) 1995-2006, AdaCore                     --
 --                                                                          --
 -- 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- --
@@ -81,9 +81,20 @@ package body System.Tasking.Protected_Objects is
 
       Initialize_Lock (Init_Priority, Object.L'Access);
       Object.Ceiling := System.Any_Priority (Init_Priority);
+      Object.New_Ceiling := System.Any_Priority (Init_Priority);
       Object.Owner := Null_Task;
    end Initialize_Protection;
 
+   -----------------
+   -- Get_Ceiling --
+   -----------------
+
+   function Get_Ceiling
+     (Object : Protection_Access) return System.Any_Priority is
+   begin
+      return Object.New_Ceiling;
+   end Get_Ceiling;
+
    ----------
    -- Lock --
    ----------
@@ -199,6 +210,17 @@ package body System.Tasking.Protected_Objects is
       end if;
    end Lock_Read_Only;
 
+   -----------------
+   -- Set_Ceiling --
+   -----------------
+
+   procedure Set_Ceiling
+     (Object : Protection_Access;
+      Prio   : System.Any_Priority) is
+   begin
+      Object.New_Ceiling := Prio;
+   end Set_Ceiling;
+
    ------------
    -- Unlock --
    ------------
index 3ff9082588de46da8dc666a315ac6486563d552c..e62f230ccfd5d6186e1d85e07350513e0ea3e530 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                  S p e c                                 --
 --                                                                          --
---          Copyright (C) 1992-2005, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2006, 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- --
@@ -45,7 +45,7 @@
 
 --  Note: the compiler generates direct calls to this interface, via Rtsfind.
 --  Any changes to this interface may require corresponding compiler changes
---  in exp_ch9.adb and possibly exp_ch7.adb
+--  in exp_ch9.adb and possibly exp_ch7.adb and exp_attr.adb
 
 package System.Tasking.Protected_Objects is
    pragma Elaborate_Body;
@@ -172,6 +172,10 @@ package System.Tasking.Protected_Objects is
 
    Null_PO : constant Protection_Access := null;
 
+   function Get_Ceiling
+     (Object : Protection_Access) return System.Any_Priority;
+   --  Returns the new ceiling priority of the protected object
+
    procedure Initialize_Protection
      (Object           : Protection_Access;
       Ceiling_Priority : Integer);
@@ -196,6 +200,11 @@ package System.Tasking.Protected_Objects is
    --  for possible future use. At the current time, everyone uses Lock
    --  for both read and write locks.
 
+   procedure Set_Ceiling
+     (Object : Protection_Access;
+      Prio   : System.Any_Priority);
+   --  Sets the new ceiling priority of the protected object
+
    procedure Unlock (Object : Protection_Access);
    --  Relinquish ownership of the lock for the object represented by
    --  the Object parameter. If this ownership was for write access, or
@@ -212,6 +221,16 @@ private
       Ceiling : System.Any_Priority;
       --  Ceiling priority associated to the protected object
 
+      New_Ceiling : System.Any_Priority;
+      --  New ceiling priority associated to the protected object. In case
+      --  of assignment of a new ceiling priority to the protected object the
+      --  frontend generates a call to set_ceiling to save the new value in
+      --  this field. After such assignment this value can be read by means
+      --  of the 'Priority attribute, which generates a call to get_ceiling.
+      --  However, the ceiling of the protected object will not be changed
+      --  until completion of the protected action in which the assignment
+      --  has been executed (AARM D.5.2 (10/2)).
+
       Owner : Task_Id;
       --  This field contains the protected object's owner. Null_Task
       --  indicates that the protected object is not currently being used.
index 6c43d7ce9629cb7b321415dbc35e897675366e04..ab64fa8d2c03102d9c6b949e7af54def2262a905 100644 (file)
@@ -473,6 +473,7 @@ package body System.Tasking.Restricted.Stages is
       Self_ID       : constant Task_Id := STPO.Self;
       Base_Priority : System.Any_Priority;
       Success       : Boolean;
+      Len           : Integer;
 
    begin
       --  Stack is not preallocated on this target, so that Stack_Address must
@@ -515,10 +516,11 @@ package body System.Tasking.Restricted.Stages is
 
       Created_Task.Entry_Calls (1).Self := Created_Task;
 
-      Created_Task.Common.Task_Image_Len :=
+      Len :=
         Integer'Min (Created_Task.Common.Task_Image'Length, Task_Image'Length);
-      Created_Task.Common.Task_Image
-        (1 .. Created_Task.Common.Task_Image_Len) := Task_Image;
+      Created_Task.Common.Task_Image_Len := Len;
+      Created_Task.Common.Task_Image (1 .. Len) :=
+        Task_Image (Task_Image'First .. Task_Image'First + Len - 1);
 
       Unlock (Self_ID);
 
index 066dbf0ead5d65ca72ba9c566a8059cbcd287697..214d7a45c17aa76c5ef66d86be517afe6a4285c1 100644 (file)
@@ -66,6 +66,17 @@ package body System.Tasking is
 
    function Self return Task_Id renames STPO.Self;
 
+   ------------------
+   -- Storage_Size --
+   ------------------
+
+   function Storage_Size (T : Task_Id) return System.Parameters.Size_Type is
+   begin
+      return
+         System.Parameters.Size_Type
+           (T.Common.Compiler_Data.Pri_Stack_Info.Size);
+   end Storage_Size;
+
    ---------------------
    -- Initialize_ATCB --
    ---------------------
index 26994efd2c9ac8327791363b389c436606a9ac9c..a9b1812b7dccd31fdab9c582bc5380fc86869eaa 100644 (file)
@@ -377,6 +377,12 @@ package System.Tasking is
    pragma Inline (Detect_Blocking);
    --  Return whether the Detect_Blocking pragma is enabled
 
+   function Storage_Size (T : Task_Id) return System.Parameters.Size_Type;
+   --  Retrieve from the TCB of the task the allocated size of its stack,
+   --  either the system default or the size specified by a pragma. This
+   --  is in general a non-static value that can depend on discriminants
+   --  of the task.
+
    ----------------------------------------------
    -- Ada_Task_Control_Block (ATCB) definition --
    ----------------------------------------------
index 182ade8415aa0ab26cf387f79041126017a93f0d..f15afc05092d81185095bbdf44e8842b50ae2475 100644 (file)
@@ -7,7 +7,7 @@
 --                                                                          --
 --                                  B o d y                                 --
 --                                                                          --
---         Copyright (C) 1998-2005, Free Software Foundation, Inc.          --
+--         Copyright (C) 1998-2006, 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- --
@@ -162,6 +162,16 @@ package body System.Tasking.Protected_Objects.Entries is
       STPO.Finalize_Lock (Object.L'Unrestricted_Access);
    end Finalize;
 
+   -----------------
+   -- Get_Ceiling --
+   -----------------
+
+   function Get_Ceiling
+     (Object : Protection_Entries_Access) return System.Any_Priority is
+   begin
+      return Object.New_Ceiling;
+   end Get_Ceiling;
+
    -------------------------------------
    -- Has_Interrupt_Or_Attach_Handler --
    -------------------------------------
@@ -349,6 +359,17 @@ package body System.Tasking.Protected_Objects.Entries is
       end if;
    end Lock_Read_Only_Entries;
 
+   -----------------
+   -- Set_Ceiling --
+   -----------------
+
+   procedure Set_Ceiling
+     (Object : Protection_Entries_Access;
+      Prio   : System.Any_Priority) is
+   begin
+      Object.New_Ceiling := Prio;
+   end Set_Ceiling;
+
    --------------------
    -- Unlock_Entries --
    --------------------
index 53ae4bf50ae3cae6b54482f956a6cab439b2d481..d19324d5a7ba7f413a664077ba379ccc262944ef 100644 (file)
@@ -7,7 +7,7 @@
 --                                                                          --
 --                                  S p e c                                 --
 --                                                                          --
---          Copyright (C) 1992-2005, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2006, 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- --
@@ -93,6 +93,16 @@ package System.Tasking.Protected_Objects.Entries is
       Ceiling : System.Any_Priority;
       --  Ceiling priority associated with the protected object
 
+      New_Ceiling : System.Any_Priority;
+      --  New ceiling priority associated to the protected object. In case
+      --  of assignment of a new ceiling priority to the protected object the
+      --  frontend generates a call to set_ceiling to save the new value in
+      --  this field. After such assignment this value can be read by means
+      --  of the 'Priority attribute, which generates a call to get_ceiling.
+      --  However, the ceiling of the protected object will not be changed
+      --  until completion of the protected action in which the assignment
+      --  has been executed (AARM D.5.2 (10/2)).
+
       Owner : Task_Id;
       --  This field contains the protected object's owner. Null_Task
       --  indicates that the protected object is not currently being used.
@@ -142,6 +152,10 @@ package System.Tasking.Protected_Objects.Entries is
    function To_Protection is
      new Unchecked_Conversion (System.Address, Protection_Entries_Access);
 
+   function Get_Ceiling
+     (Object : Protection_Entries_Access) return System.Any_Priority;
+   --  Returns the new ceiling priority of the protected object
+
    function Has_Interrupt_Or_Attach_Handler
      (Object : Protection_Entries_Access) return Boolean;
    --  Returns True if an Interrupt_Handler or Attach_Handler pragma applies
@@ -183,6 +197,11 @@ package System.Tasking.Protected_Objects.Entries is
    --  possible future use. At the current time, everyone uses Lock for both
    --  read and write locks.
 
+   procedure Set_Ceiling
+     (Object : Protection_Entries_Access;
+      Prio   : System.Any_Priority);
+   --  Sets the new ceiling priority of the protected object
+
    procedure Unlock_Entries (Object : Protection_Entries_Access);
    --  Relinquish ownership of the lock for the object represented by the
    --  Object parameter. If this ownership was for write access, or if it was