1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- S Y S T E M . T H R E A D S . I N I T I A L I Z A T I O N --
9 -- Copyright (C) 1992-2003 Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 -- This is the VxWorks version of this package; to use this implementation,
35 -- the task hook libraries should be included in the VxWorks kernel.
37 with System.Secondary_Stack;
38 with System.Storage_Elements;
39 with System.Soft_Links;
42 package body System.Threads.Initialization is
46 package SSS renames System.Secondary_Stack;
48 package SSL renames System.Soft_Links;
50 procedure Initialize_Task_Hooks;
51 -- Register the appropriate hooks (Register and Reset_TSD) to the
52 -- underlying OS, so that they will be called when a task is created
55 Current_ATSD : aliased System.Address;
56 pragma Import (C, Current_ATSD, "__gnat_current_atsd");
58 ---------------------------
59 -- Initialize_Task_Hooks --
60 ---------------------------
62 procedure Initialize_Task_Hooks is separate;
63 -- Separate, as these hooks are different for AE653 and VxWorks 5.5.
71 SSL.Get_Jmpbuf_Address := Get_Jmpbuf_Address'Access;
72 SSL.Get_Sec_Stack_Addr := Get_Sec_Stack_Addr'Access;
73 SSL.Get_Current_Excep := Get_Current_Excep'Access;
74 SSL.Set_Jmpbuf_Address := Set_Jmpbuf_Address'Access;
75 SSL.Set_Sec_Stack_Addr := Set_Sec_Stack_Addr'Access;
82 function Register (T : OSI.Thread_Id) return OSI.STATUS is
85 -- It cannot be assumed that the caller of this routine has a ATSD;
86 -- so neither this procedure nor the procedures that it calls should
87 -- raise or handle exceptions, or make use of a secondary stack.
89 -- This routine is only necessary because taskVarAdd cannot be
90 -- executed once an AE653 partition has entered normal mode
91 -- (depending on configRecord.c, allocation could be disabled).
92 -- Otherwise, everything could have been done in Thread_Body_Enter.
94 if OSI.taskIdVerify (T) = OSI.ERROR then
98 Result := OSI.taskVarAdd (T, Current_ATSD'Access);
99 pragma Assert (Result /= OSI.ERROR);
104 subtype Default_Sec_Stack is
105 System.Storage_Elements.Storage_Array
106 (1 .. SSS.Default_Secondary_Stack_Size);
108 Main_Sec_Stack : aliased Default_Sec_Stack;
110 -- Secondary stack for environment task
112 Main_ATSD : aliased ATSD;
114 -- TSD for environment task
117 Initialize_Task_Hooks;
119 -- Register the environment task
121 Result : Interfaces.C.int := Register (OSI.taskIdSelf);
122 pragma Assert (Result /= OSI.ERROR);
125 (Main_Sec_Stack'Address,
126 Main_Sec_Stack'Size / System.Storage_Unit,
129 end System.Threads.Initialization;