source: rtems/cpukit/rtems/src/tasks.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 7.0 KB
Line 
1/*
2 *  RTEMS Task Manager -- Initialize Manager
3 *
4 *  COPYRIGHT (c) 1989-2009.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/system.h>
17#include <rtems/config.h>
18#include <rtems/rtems/status.h>
19#include <rtems/rtems/support.h>
20#include <rtems/rtems/modes.h>
21#include <rtems/score/object.h>
22#include <rtems/score/stack.h>
23#include <rtems/score/states.h>
24#include <rtems/rtems/tasks.h>
25#include <rtems/score/thread.h>
26#include <rtems/score/threadq.h>
27#include <rtems/score/tod.h>
28#include <rtems/score/userext.h>
29#include <rtems/score/wkspace.h>
30#include <rtems/score/apiext.h>
31#include <rtems/score/sysstate.h>
32
33/*
34 *  _RTEMS_tasks_Create_extension
35 *
36 *  This routine is an extension routine that is invoked as part
37 *  of creating any type of task or thread in the system.  If the
38 *  task is created via another API, then this routine is invoked
39 *  and this API given the opportunity to initialize its extension
40 *  area.
41 */
42
43static bool _RTEMS_tasks_Create_extension(
44  Thread_Control *executing,
45  Thread_Control *created
46)
47{
48  RTEMS_API_Control *api;
49  int                i;
50  size_t             to_allocate;
51
52  /*
53   *  Notepads must be the last entry in the structure and they
54   *  can be left off if disabled in the configuration.
55   */
56  to_allocate = sizeof( RTEMS_API_Control );
57  if ( !rtems_configuration_get_notepads_enabled() )
58    to_allocate -= (RTEMS_NUMBER_NOTEPADS * sizeof(uint32_t));
59
60  api = _Workspace_Allocate( to_allocate );
61
62  if ( !api )
63    return false;
64
65  created->API_Extensions[ THREAD_API_RTEMS ] = api;
66
67  api->pending_events = EVENT_SETS_NONE_PENDING;
68  api->event_condition = 0;
69  _ASR_Initialize( &api->Signal );
70  created->task_variables = NULL;
71
72  if ( rtems_configuration_get_notepads_enabled() ) {
73    for (i=0; i < RTEMS_NUMBER_NOTEPADS; i++)
74      api->Notepads[i] = 0;
75  }
76
77  return true;
78}
79
80/*
81 *  _RTEMS_tasks_Start_extension
82 *
83 *  This extension routine is invoked when a task is started for the
84 *  first time.
85 */
86
87static void _RTEMS_tasks_Start_extension(
88  Thread_Control *executing,
89  Thread_Control *started
90)
91{
92  RTEMS_API_Control *api;
93
94  api = started->API_Extensions[ THREAD_API_RTEMS ];
95
96  api->pending_events = EVENT_SETS_NONE_PENDING;
97}
98
99/*
100 *  _RTEMS_tasks_Delete_extension
101 *
102 *  This extension routine is invoked when a task is deleted.
103 */
104
105static void _RTEMS_tasks_Delete_extension(
106  Thread_Control *executing,
107  Thread_Control *deleted
108)
109{
110  rtems_task_variable_t *tvp, *next;
111
112  /*
113   *  Free per task variable memory
114   */
115
116  tvp = deleted->task_variables;
117  deleted->task_variables = NULL;
118  while (tvp) {
119    next = (rtems_task_variable_t *)tvp->next;
120    _RTEMS_Tasks_Invoke_task_variable_dtor( deleted, tvp );
121    tvp = next;
122  }
123
124  /*
125   *  Free API specific memory
126   */
127
128  (void) _Workspace_Free( deleted->API_Extensions[ THREAD_API_RTEMS ] );
129  deleted->API_Extensions[ THREAD_API_RTEMS ] = NULL;
130}
131
132/*
133 *  _RTEMS_tasks_Switch_extension
134 *
135 *  This extension routine is invoked at each context switch.
136 */
137
138static void _RTEMS_tasks_Switch_extension(
139  Thread_Control *executing,
140  Thread_Control *heir
141)
142{
143  rtems_task_variable_t *tvp;
144
145  /*
146   *  Per Task Variables
147   */
148
149  tvp = executing->task_variables;
150  while (tvp) {
151    tvp->tval = *tvp->ptr;
152    *tvp->ptr = tvp->gval;
153    tvp = (rtems_task_variable_t *)tvp->next;
154  }
155
156  tvp = heir->task_variables;
157  while (tvp) {
158    tvp->gval = *tvp->ptr;
159    *tvp->ptr = tvp->tval;
160    tvp = (rtems_task_variable_t *)tvp->next;
161  }
162}
163
164/*
165 *  _RTEMS_tasks_Post_switch_extension
166 *
167 *  This extension routine is invoked at each context switch.
168 */
169
170static void _RTEMS_tasks_Post_switch_extension(
171  Thread_Control *executing
172)
173{
174  ISR_Level          level;
175  RTEMS_API_Control *api;
176  ASR_Information   *asr;
177  rtems_signal_set   signal_set;
178  Modes_Control      prev_mode;
179
180  api = executing->API_Extensions[ THREAD_API_RTEMS ];
181  if ( !api )
182    return;
183
184  /*
185   *  Signal Processing
186   */
187
188  asr = &api->Signal;
189
190  _ISR_Disable( level );
191    signal_set = asr->signals_posted;
192    asr->signals_posted = 0;
193  _ISR_Enable( level );
194
195
196  if ( !signal_set ) /* similar to _ASR_Are_signals_pending( asr ) */
197    return;
198
199  asr->nest_level += 1;
200  rtems_task_mode( asr->mode_set, RTEMS_ALL_MODE_MASKS, &prev_mode );
201
202  (*asr->handler)( signal_set );
203
204  asr->nest_level -= 1;
205  rtems_task_mode( prev_mode, RTEMS_ALL_MODE_MASKS, &prev_mode );
206
207}
208
209API_extensions_Control _RTEMS_tasks_API_extensions = {
210  { NULL, NULL },
211  #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
212    NULL,                                   /* predriver */
213  #endif
214  _RTEMS_tasks_Initialize_user_tasks,       /* postdriver */
215  _RTEMS_tasks_Post_switch_extension        /* post switch */
216};
217
218User_extensions_Control _RTEMS_tasks_User_extensions = {
219  { NULL, NULL },
220  { { NULL, NULL }, _RTEMS_tasks_Switch_extension },
221  { _RTEMS_tasks_Create_extension,            /* create */
222    _RTEMS_tasks_Start_extension,             /* start */
223    _RTEMS_tasks_Start_extension,             /* restart */
224    _RTEMS_tasks_Delete_extension,            /* delete */
225    _RTEMS_tasks_Switch_extension,            /* switch */
226    NULL,                                     /* begin */
227    NULL,                                     /* exitted */
228    NULL                                      /* fatal */
229  }
230};
231
232/*
233 *  _RTEMS_tasks_Manager_initialization
234 *
235 *  This routine initializes all Task Manager related data structures.
236 *
237 *  Input parameters: NONE
238 *
239 *  Output parameters:  NONE
240 */
241
242void _RTEMS_tasks_Manager_initialization(void)
243{
244  _Objects_Initialize_information(
245    &_RTEMS_tasks_Information, /* object information table */
246    OBJECTS_CLASSIC_API,       /* object API */
247    OBJECTS_RTEMS_TASKS,       /* object class */
248    Configuration_RTEMS_API.maximum_tasks,
249                               /* maximum objects of this class */
250    sizeof( Thread_Control ),  /* size of this object's control block */
251    false,                     /* true if the name is a string */
252    RTEMS_MAXIMUM_NAME_LENGTH  /* maximum length of an object name */
253#if defined(RTEMS_MULTIPROCESSING)
254    ,
255    true,                      /* true if this is a global object class */
256    NULL                       /* Proxy extraction support callout */
257#endif
258  );
259
260  /*
261   *  Add all the extensions for this API
262   */
263
264  _User_extensions_Add_API_set( &_RTEMS_tasks_User_extensions );
265
266  _API_extensions_Add( &_RTEMS_tasks_API_extensions );
267
268  /*
269   *  Register the MP Process Packet routine.
270   */
271
272#if defined(RTEMS_MULTIPROCESSING)
273  _MPCI_Register_packet_processor(
274    MP_PACKET_TASKS,
275    _RTEMS_tasks_MP_Process_packet
276  );
277#endif
278
279}
280
281/*
282 *  _RTEMS_tasks_Initialize_user_tasks
283 *
284 *  This routine creates and starts all configured user
285 *  initialization threads.
286 *
287 *  Input parameters: NONE
288 *
289 *  Output parameters:  NONE
290 */
291
292void _RTEMS_tasks_Initialize_user_tasks( void )
293{
294  if ( _RTEMS_tasks_Initialize_user_tasks_p )
295    (*_RTEMS_tasks_Initialize_user_tasks_p)();
296}
Note: See TracBrowser for help on using the repository browser.