Ticket #142: tswitch-speedup.diff

File tswitch-speedup.diff, 8.1 KB (added by Chris Johns, on 12/03/06 at 13:31:13)

tswitch-speedup.diff

Line 
1Index: posix/src/pthread.c
2===================================================================
3RCS file: /usr1/CVS/rtems/c/src/exec/posix/src/pthread.c,v
4retrieving revision 1.54
5diff -c -r1.54 pthread.c
6*** posix/src/pthread.c 2001/01/24 14:17:28     1.54
7--- posix/src/pthread.c 2002/03/19 12:59:09
8***************
9*** 311,316 ****
10--- 311,317 ----
11   
12  User_extensions_Control _POSIX_Threads_User_extensions = {
13    { NULL, NULL },
14+   { { NULL, NULL }, NULL },
15    { _POSIX_Threads_Create_extension,          /* create */
16      NULL,                                     /* start */
17      NULL,                                     /* restart */
18Index: rtems/src/tasks.c
19===================================================================
20RCS file: /usr1/CVS/rtems/c/src/exec/rtems/src/tasks.c,v
21retrieving revision 1.35
22diff -c -r1.35 tasks.c
23*** rtems/src/tasks.c   2001/09/21 13:57:57     1.35
24--- rtems/src/tasks.c   2002/03/19 12:59:09
25***************
26*** 205,210 ****
27--- 205,211 ----
28 
29  User_extensions_Control _RTEMS_tasks_User_extensions = {
30    { NULL, NULL },
31+   { { NULL, NULL }, NULL },
32    { _RTEMS_tasks_Create_extension,            /* create */
33      _RTEMS_tasks_Start_extension,             /* start */
34      _RTEMS_tasks_Start_extension,             /* restart */
35Index: score/include/rtems/score/userext.h
36===================================================================
37RCS file: /usr1/CVS/rtems/c/src/exec/score/include/rtems/score/userext.h,v
38retrieving revision 1.15
39diff -c -r1.15 userext.h
40*** score/include/rtems/score/userext.h 1999/11/17 17:50:37     1.15
41--- score/include/rtems/score/userext.h 2002/03/19 12:59:09
42***************
43*** 91,102 ****
44  }   User_extensions_Table;
45 
46  /*
47   *  The following is used to manage each user extension set.
48   */
49 
50  typedef struct {
51!   Chain_Node              Node;
52!   User_extensions_Table   Callouts;
53  }   User_extensions_Control;
54 
55  /*
56--- 91,115 ----
57  }   User_extensions_Table;
58 
59  /*
60+  *  The following is used to manage the list of switch handlers.
61+  */
62+
63+ typedef struct {
64+   Chain_Node                              Node;
65+   User_extensions_thread_switch_extension thread_switch;
66+ }   User_extensions_switch_Control;
67+
68+ /*
69   *  The following is used to manage each user extension set.
70+  *  The switch control is part of the extensions control even
71+  *  if not used due to the extension not having a switch
72+  *  handler.
73   */
74 
75  typedef struct {
76!   Chain_Node                     Node;
77!   User_extensions_switch_Control Switch;
78!   User_extensions_Table          Callouts;
79  }   User_extensions_Control;
80 
81  /*
82***************
83*** 104,109 ****
84--- 117,129 ----
85   */
86 
87  SCORE_EXTERN Chain_Control _User_extensions_List;
88+
89+ /*
90+  *  The following is used to manage a chain of user extension task
91+  *  switch nodes.
92+  */
93+
94+ SCORE_EXTERN Chain_Control _User_extensions_switches_List;
95 
96  /*
97   *  _User_extensions_Thread_create
98Index: score/inline/rtems/score/userext.inl
99===================================================================
100RCS file: /usr1/CVS/rtems/c/src/exec/score/inline/rtems/score/userext.inl,v
101retrieving revision 1.13
102diff -c -r1.13 userext.inl
103*** score/inline/rtems/score/userext.inl        1999/11/17 17:50:37     1.13
104--- score/inline/rtems/score/userext.inl        2002/03/19 12:59:09
105***************
106*** 20,70 ****
107 
108  /*PAGE
109   *
110!  *  _User_extensions_Handler_initialization
111   *
112   *  DESCRIPTION:
113   *
114!  *  This routine performs the initialization necessary for this handler.
115   */
116 
117! RTEMS_INLINE_ROUTINE void _User_extensions_Handler_initialization (
118!     unsigned32              number_of_extensions,
119!     User_extensions_Table  *initial_extensions
120  )
121  {
122!   User_extensions_Control *extension;
123!   unsigned32               i;
124!
125!   _Chain_Initialize_empty( &_User_extensions_List );
126 
127!   if ( initial_extensions ) {
128!     for (i=0 ; i<number_of_extensions ; i++ ) {
129!       extension =
130!          _Workspace_Allocate_or_fatal_error( sizeof(User_extensions_Control) );
131 
132!       extension->Callouts = initial_extensions[i];
133!       _Chain_Append( &_User_extensions_List, &extension->Node );
134!     }
135    }
136  }
137 
138  /*PAGE
139   *
140!  *  _User_extensions_Add_set
141   *
142   *  DESCRIPTION:
143   *
144!  *  This routine is used to add a user extension set to the active list.
145   */
146 
147! RTEMS_INLINE_ROUTINE void _User_extensions_Add_set (
148!   User_extensions_Control *the_extension,
149!   User_extensions_Table   *extension_table
150  )
151  {
152!   the_extension->Callouts = *extension_table;
153 
154!   _Chain_Append( &_User_extensions_List, &the_extension->Node );
155  }
156 
157  /*PAGE
158--- 20,87 ----
159 
160  /*PAGE
161   *
162!  *  _User_extensions_Add_set
163   *
164   *  DESCRIPTION:
165   *
166!  *  This routine is used to add a user extension set to the active list.
167   */
168 
169! RTEMS_INLINE_ROUTINE void _User_extensions_Add_set (
170!   User_extensions_Control *the_extension,
171!   User_extensions_Table   *extension_table
172  )
173  {
174!   the_extension->Callouts = *extension_table;
175 
176!   _Chain_Append( &_User_extensions_List, &the_extension->Node );
177 
178!   /*
179!    * If a switch handler is present, append it to the switch chain.
180!    */
181!   if ( extension_table->thread_switch != NULL ) {
182!     the_extension->Switch.thread_switch = extension_table->thread_switch;
183!     _Chain_Append( &_User_extensions_switches_List, &the_extension->Switch.Node );
184    }
185  }
186 
187  /*PAGE
188   *
189!  *  _User_extensions_Handler_initialization
190   *
191   *  DESCRIPTION:
192   *
193!  *  This routine performs the initialization necessary for this handler.
194   */
195 
196! RTEMS_INLINE_ROUTINE void _User_extensions_Handler_initialization (
197!     unsigned32              number_of_extensions,
198!     User_extensions_Table  *initial_extensions
199  )
200  {
201!   User_extensions_Control *extension;
202!   unsigned32               i;
203 
204!   _Chain_Initialize_empty( &_User_extensions_List );
205!   _Chain_Initialize_empty( &_User_extensions_switches_List );
206!
207!   if ( initial_extensions ) {
208!     extension =
209!       _Workspace_Allocate_or_fatal_error(
210!         number_of_extensions * sizeof( User_extensions_Control )
211!       );
212!   
213!     memset (
214!       extension,
215!       0,
216!       number_of_extensions * sizeof( User_extensions_Control )
217!     );
218!   
219!     for ( i = 0 ; i < number_of_extensions ; i++ ) {
220!       _User_extensions_Add_set (extension, &initial_extensions[i]);
221!       extension++;
222!     }
223!   }
224  }
225 
226  /*PAGE
227***************
228*** 80,87 ****
229  )
230  {
231    _Chain_Prepend( &_User_extensions_List, &the_extension->Node );
232  }
233
234  /*PAGE
235   *
236   *  _User_extensions_Remove_set
237--- 97,112 ----
238  )
239  {
240    _Chain_Prepend( &_User_extensions_List, &the_extension->Node );
241+
242+   /*
243+    * If a switch handler is present, append it to the switch chain.
244+    */
245+   if ( the_extension->Callouts.thread_switch != NULL ) {
246+     the_extension->Switch.thread_switch = the_extension->Callouts.thread_switch;
247+     _Chain_Prepend( &_User_extensions_switches_List, &the_extension->Switch.Node );
248+   }
249  }
250!
251  /*PAGE
252   *
253   *  _User_extensions_Remove_set
254***************
255*** 96,101 ****
256--- 121,133 ----
257  )
258  {
259    _Chain_Extract( &the_extension->Node );
260+   
261+   /*
262+    * If a switch handler is present, remove it.
263+    */
264+
265+   if ( the_extension->Callouts.thread_switch != NULL )
266+     _Chain_Extract( &the_extension->Switch.Node );
267  }
268 
269  /*PAGE
270***************
271*** 113,129 ****
272    Thread_Control *heir
273  )
274  {
275!   Chain_Node              *the_node;
276!   User_extensions_Control *the_extension;
277!
278!   for ( the_node = _User_extensions_List.first ;
279!         !_Chain_Is_tail( &_User_extensions_List, the_node ) ;
280          the_node = the_node->next ) {
281 
282!     the_extension = (User_extensions_Control *) the_node;
283 
284!     if ( the_extension->Callouts.thread_switch != NULL )
285!       (*the_extension->Callouts.thread_switch)( executing, heir );
286    }
287  }
288 
289--- 145,160 ----
290    Thread_Control *heir
291  )
292  {
293!   Chain_Node                     *the_node;
294!   User_extensions_switch_Control *the_extension_switch;
295!   
296!   for ( the_node = _User_extensions_switches_List.first ;
297!         !_Chain_Is_tail( &_User_extensions_switches_List, the_node ) ;
298          the_node = the_node->next ) {
299 
300!     the_extension_switch = (User_extensions_switch_Control *) the_node;
301 
302!     (*the_extension_switch->thread_switch)( executing, heir );
303    }
304  }
305