OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [ada/] [s-tporft.adb] - Blame information for rev 473

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
4
--                                                                          --
5
--         SYSTEM.TASK_PRIMITIVES.OPERATIONS.REGISTER_FOREIGN_THREAD        --
6
--                                                                          --
7
--                                B o d y                                   --
8
--                                                                          --
9
--          Copyright (C) 2002-2009, Free Software Foundation, Inc.         --
10
--                                                                          --
11
-- GNARL 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 3,  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.                                     --
17
--                                                                          --
18
-- As a special exception under Section 7 of GPL version 3, you are granted --
19
-- additional permissions described in the GCC Runtime Library Exception,   --
20
-- version 3.1, as published by the Free Software Foundation.               --
21
--                                                                          --
22
-- You should have received a copy of the GNU General Public License and    --
23
-- a copy of the GCC Runtime Library Exception along with this program;     --
24
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
27
-- GNARL was developed by the GNARL team at Florida State University.       --
28
-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
29
--                                                                          --
30
------------------------------------------------------------------------------
31
 
32
with System.Task_Info;
33
--  Use for Unspecified_Task_Info
34
 
35
with System.Soft_Links;
36
--  used to initialize TSD for a C thread, in function Self
37
 
38
separate (System.Task_Primitives.Operations)
39
function Register_Foreign_Thread (Thread : Thread_Id) return Task_Id is
40
   Local_ATCB : aliased Ada_Task_Control_Block (0);
41
   Self_Id    : Task_Id;
42
   Succeeded  : Boolean;
43
 
44
begin
45
   --  This section is tricky. We must not call anything that might require
46
   --  an ATCB, until the new ATCB is in place. In order to get an ATCB
47
   --  immediately, we fake one, so that it is then possible to e.g allocate
48
   --  memory (which might require accessing self).
49
 
50
   --  Record this as the Task_Id for the thread
51
 
52
   Local_ATCB.Common.LL.Thread := Thread;
53
   Local_ATCB.Common.Current_Priority := System.Priority'First;
54
   Specific.Set (Local_ATCB'Unchecked_Access);
55
 
56
   --  It is now safe to use an allocator
57
 
58
   Self_Id := new Ada_Task_Control_Block (0);
59
 
60
   --  Finish initialization
61
 
62
   Lock_RTS;
63
   System.Tasking.Initialize_ATCB
64
     (Self_Id, null, Null_Address, Null_Task,
65
      Foreign_Task_Elaborated'Access,
66
      System.Priority'First, Task_Info.Unspecified_Task_Info, 0, Self_Id,
67
      Succeeded);
68
   Unlock_RTS;
69
   pragma Assert (Succeeded);
70
 
71
   Self_Id.Master_of_Task := 0;
72
   Self_Id.Master_Within := Self_Id.Master_of_Task + 1;
73
 
74
   for L in Self_Id.Entry_Calls'Range loop
75
      Self_Id.Entry_Calls (L).Self := Self_Id;
76
      Self_Id.Entry_Calls (L).Level := L;
77
   end loop;
78
 
79
   Self_Id.Common.State := Runnable;
80
   Self_Id.Awake_Count := 1;
81
 
82
   Self_Id.Common.Task_Image (1 .. 14) := "foreign thread";
83
   Self_Id.Common.Task_Image_Len := 14;
84
 
85
   --  Since this is not an ordinary Ada task, we will start out undeferred
86
 
87
   Self_Id.Deferral_Level := 0;
88
 
89
   System.Soft_Links.Create_TSD (Self_Id.Common.Compiler_Data);
90
 
91
   --  ???
92
   --  The following call is commented out to avoid dependence on
93
   --  the System.Tasking.Initialization package.
94
   --  It seems that if we want Ada.Task_Attributes to work correctly
95
   --  for C threads we will need to raise the visibility of this soft
96
   --  link to System.Soft_Links.
97
   --  We are putting that off until this new functionality is otherwise
98
   --  stable.
99
 
100
   --  System.Tasking.Initialization.Initialize_Attributes_Link.all (T);
101
 
102
   Enter_Task (Self_Id);
103
 
104
   return Self_Id;
105
end Register_Foreign_Thread;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.