Priority : System.Any_Priority;
Succeeded : out Boolean)
is
- Attributes : aliased pthread_attr_t;
- Adjusted_Stack_Size : Interfaces.C.size_t;
- Result : Interfaces.C.int;
+ Attributes : aliased pthread_attr_t;
+ Result : Interfaces.C.int;
function Thread_Body_Access is new
Unchecked_Conversion (System.Address, Thread_Body);
begin
- if Stack_Size = Unspecified_Size then
- Adjusted_Stack_Size := Interfaces.C.size_t (Default_Stack_Size);
-
- elsif Stack_Size < Minimum_Stack_Size then
- Adjusted_Stack_Size := Interfaces.C.size_t (Minimum_Stack_Size);
-
- else
- Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size);
- end if;
-
Result := pthread_attr_init (Attributes'Access);
pragma Assert (Result = 0 or else Result = ENOMEM);
end if;
Result := pthread_attr_setstacksize
- (Attributes'Access, Adjusted_Stack_Size);
+ (Attributes'Access, Interfaces.C.size_t (Stack_Size));
pragma Assert (Result = 0);
-- Since the initial signal mask of a thread is inherited from the
-- --
-- B o d y --
-- --
--- 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- --
with System.IO;
-- used for Put_Line
-with System.Parameters;
--- used for Size_Type
-
-with System.Program_Info;
--- used for Default_Task_Stack
--- Default_Time_Slice
--- Stack_Guard_Pages
--- Pthread_Sched_Signal
--- Pthread_Arena_Size
-
-with System.OS_Interface;
--- used for various type, constant, and operations
-
with Unchecked_Conversion;
with Unchecked_Deallocation;
is
use System.Task_Info;
- Attributes : aliased pthread_attr_t;
- Sched_Param : aliased struct_sched_param;
- Adjusted_Stack_Size : Interfaces.C.size_t;
- Result : Interfaces.C.int;
+ Attributes : aliased pthread_attr_t;
+ Sched_Param : aliased struct_sched_param;
+ Result : Interfaces.C.int;
function Thread_Body_Access is new
Unchecked_Conversion (System.Address, Thread_Body);
(System.Task_Info.Thread_Scheduling_Policy, Interfaces.C.int);
begin
- if Stack_Size = System.Parameters.Unspecified_Size then
- Adjusted_Stack_Size :=
- Interfaces.C.size_t (System.Program_Info.Default_Task_Stack);
-
- elsif Stack_Size < Size_Type (Minimum_Stack_Size) then
- Adjusted_Stack_Size :=
- Interfaces.C.size_t (Minimum_Stack_Size);
-
- else
- Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size);
- end if;
-
Result := pthread_attr_init (Attributes'Access);
pragma Assert (Result = 0 or else Result = ENOMEM);
pragma Assert (Result = 0);
Result := pthread_attr_setstacksize
- (Attributes'Access, Adjusted_Stack_Size);
+ (Attributes'Access, Interfaces.C.size_t (Stack_Size));
pragma Assert (Result = 0);
if T.Common.Task_Info /= null then
-- --
-- B o d y --
-- --
--- 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- --
-- used for int
-- size_t
-with System.Parameters;
--- used for Size_Type
-
with System.Tasking.Debug;
-- used for Known_Tasks
Priority : System.Any_Priority;
Succeeded : out Boolean)
is
- Adjusted_Stack_Size : Interfaces.C.size_t;
-
Attributes : aliased pthread_attr_t;
Result : Interfaces.C.int;
begin
- if Stack_Size = Unspecified_Size then
- Adjusted_Stack_Size := Interfaces.C.size_t (Default_Stack_Size);
-
- elsif Stack_Size < Minimum_Stack_Size then
- Adjusted_Stack_Size := Interfaces.C.size_t (Minimum_Stack_Size);
-
- else
- Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size);
- end if;
-
Result := pthread_attr_init (Attributes'Access);
pragma Assert (Result = 0 or else Result = ENOMEM);
Result :=
pthread_attr_setstacksize
- (Attributes'Access, Adjusted_Stack_Size);
+ (Attributes'Access, Interfaces.C.size_t (Stack_Size));
pragma Assert (Result = 0);
Result :=
-- --
-- B o d y --
-- --
--- 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- --
-- used for int
-- size_t
-with System.Parameters;
--- used for Size_Type
-
with Unchecked_Deallocation;
package body System.Task_Primitives.Operations is
use System.Task_Info;
begin
- if Stack_Size = Unspecified_Size then
- Adjusted_Stack_Size := Interfaces.C.size_t (Default_Stack_Size);
-
- elsif Stack_Size < Minimum_Stack_Size then
- Adjusted_Stack_Size := Interfaces.C.size_t (Minimum_Stack_Size);
-
- else
- Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size);
- end if;
+ Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size);
if Stack_Base_Available then
-- --
-- B o d y --
-- --
--- 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- --
-- used for int
-- size_t
-with System.Parameters;
--- used for Size_Type
-
with Unchecked_Conversion;
with Unchecked_Deallocation;
use System.Task_Info;
begin
- if Stack_Size = Unspecified_Size then
- Adjusted_Stack_Size := Interfaces.C.size_t (Default_Stack_Size);
-
- elsif Stack_Size < Minimum_Stack_Size then
- Adjusted_Stack_Size := Interfaces.C.size_t (Minimum_Stack_Size);
-
- else
- Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size);
- end if;
+ Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size);
if Stack_Base_Available then
-- If Stack Checking is supported then allocate 2 additional pages:
-- --
-- B o d y --
-- --
--- 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- --
-- used for int
-- size_t
-with System.Parameters;
--- used for Size_Type
-
with System.Task_Info;
-- to initialize Task_Info for a C thread, in function Self
is
pragma Unreferenced (Priority);
- Result : Interfaces.C.int;
+ Result : Interfaces.C.int;
Adjusted_Stack_Size : Interfaces.C.size_t;
- Opts : Interfaces.C.int := THR_DETACHED;
+ Opts : Interfaces.C.int := THR_DETACHED;
- Page_Size : constant System.Parameters.Size_Type := 4096;
+ Page_Size : constant System.Parameters.Size_Type := 4096;
-- This constant is for reserving extra space at the
-- end of the stack, which can be used by the stack
-- checking as guard page. The idea is that we need
use System.Task_Info;
begin
- if Stack_Size = System.Parameters.Unspecified_Size then
- Adjusted_Stack_Size :=
- Interfaces.C.size_t (Default_Stack_Size + Page_Size);
-
- elsif Stack_Size < Minimum_Stack_Size then
- Adjusted_Stack_Size :=
- Interfaces.C.size_t (Minimum_Stack_Size + Page_Size);
-
- else
- Adjusted_Stack_Size :=
- Interfaces.C.size_t (Stack_Size + Page_Size);
- end if;
+ Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size + Page_Size);
-- Since the initial signal mask of a thread is inherited from the
-- creator, and the Environment task has all its signals masked, we
-- --
-- B o d y --
-- --
--- 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- --
-- used for int
-- size_t
-with System.Parameters;
--- used for Size_Type
-
with Unchecked_Deallocation;
package body System.Task_Primitives.Operations is
use System.Task_Info;
begin
- if Stack_Size = Unspecified_Size then
- Adjusted_Stack_Size := Interfaces.C.size_t (Default_Stack_Size);
-
- elsif Stack_Size < Minimum_Stack_Size then
- Adjusted_Stack_Size := Interfaces.C.size_t (Minimum_Stack_Size);
-
- else
- Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size);
- end if;
-
-- Account for the Yellow Zone (2 pages) and the guard page
-- right above. See Hide_Yellow_Zone for the rationale.
- Adjusted_Stack_Size := Adjusted_Stack_Size + 3 * Get_Page_Size;
+ Adjusted_Stack_Size :=
+ Interfaces.C.size_t (Stack_Size) + 3 * Get_Page_Size;
Result := pthread_attr_init (Attributes'Access);
pragma Assert (Result = 0 or else Result = ENOMEM);
-- --
-- B o d y --
-- --
--- 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- --
-- used for int
-- size_t
-with System.Parameters;
--- used for Size_Type
-
with System.Soft_Links;
-- used for Get_Exc_Stack_Addr
Priority : System.Any_Priority;
Succeeded : out Boolean)
is
- Attributes : aliased pthread_attr_t;
- Adjusted_Stack_Size : Interfaces.C.size_t;
- Result : Interfaces.C.int;
+ Attributes : aliased pthread_attr_t;
+ Result : Interfaces.C.int;
function Thread_Body_Access is new
Unchecked_Conversion (System.Address, Thread_Body);
begin
- if Stack_Size = Unspecified_Size then
- Adjusted_Stack_Size := Interfaces.C.size_t (Default_Stack_Size);
-
- elsif Stack_Size < Minimum_Stack_Size then
- Adjusted_Stack_Size := Interfaces.C.size_t (Minimum_Stack_Size);
-
- else
- Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size);
- end if;
-
-- Since the initial signal mask of a thread is inherited from the
-- creator, we need to set our local signal mask mask all signals
-- during the creation operation, to make sure the new thread is
pragma Assert (Result = 0);
Result := pthread_attr_setstacksize
- (Attributes'Access, Adjusted_Stack_Size);
+ (Attributes'Access, Interfaces.C.size_t (Stack_Size));
pragma Assert (Result = 0);
-- This call may be unnecessary, not sure. ???
-- --
-- B o d y --
-- --
--- 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- --
-- Turn off polling, we do not want ATC polling to take place during
-- tasking operations. It causes infinite loops and other problems.
-with System.Tasking;
--- used for Ada_Task_Control_Block
--- Task_Id
--- ATCB components and types
-
with System.Tasking.Debug;
-- used for Known_Tasks
-- Signal_ID
-- Initialize_Interrupts
-with System.OS_Interface;
--- used for various type, constant, and operations
-
-with System.Parameters;
--- used for Size_Type
-
with Interfaces.C;
with Unchecked_Conversion;
is
Adjusted_Stack_Size : size_t;
begin
- if Stack_Size = Unspecified_Size then
- Adjusted_Stack_Size := size_t (Default_Stack_Size);
-
- elsif Stack_Size < Minimum_Stack_Size then
- Adjusted_Stack_Size := size_t (Minimum_Stack_Size);
-
- else
- Adjusted_Stack_Size := size_t (Stack_Size);
- end if;
-
-- Ask for four extra bytes of stack space so that the ATCB pointer can
-- be stored below the stack limit, plus extra space for the frame of
-- Task_Wrapper. This is so the user gets the amount of stack requested
-- ??? - we should come back and visit this so we can set the task name
-- to something appropriate.
- Adjusted_Stack_Size := Adjusted_Stack_Size + 2048;
+ Adjusted_Stack_Size := size_t (Stack_Size) + 2048;
-- Since the initial signal mask of a thread is inherited from the
-- creator, and the Environment task has all its signals masked, we do