source: rtems/cpukit/rtems/src/tasks.c @ 217b3f53

4.115
Last change on this file since 217b3f53 was 217b3f53, checked in by Joel Sherrill <joel.sherrill@…>, on 03/14/15 at 16:04:25

Disable deprecated warning on implementation of deprecated methods

  • Property mode set to 100644
File size: 6.3 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Task API Extensions
5 *  @ingroup ClassicTasks
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/config.h>
23#include <rtems/rtems/asrimpl.h>
24#include <rtems/rtems/eventimpl.h>
25#include <rtems/rtems/signalimpl.h>
26#include <rtems/rtems/status.h>
27#include <rtems/rtems/support.h>
28#include <rtems/rtems/modes.h>
29#include <rtems/rtems/tasksimpl.h>
30#include <rtems/posix/keyimpl.h>
31#include <rtems/score/stack.h>
32#include <rtems/score/threadimpl.h>
33#include <rtems/score/userextimpl.h>
34#include <rtems/score/wkspace.h>
35#include <rtems/score/apiext.h>
36
37/*
38 *  _RTEMS_tasks_Create_extension
39 *
40 *  This routine is an extension routine that is invoked as part
41 *  of creating any type of task or thread in the system.  If the
42 *  task is created via another API, then this routine is invoked
43 *  and this API given the opportunity to initialize its extension
44 *  area.
45 */
46
47static bool _RTEMS_tasks_Create_extension(
48  Thread_Control *executing,
49  Thread_Control *created
50)
51{
52  RTEMS_API_Control *api;
53  size_t             i;
54
55  api = created->API_Extensions[ THREAD_API_RTEMS ];
56
57  _ASR_Create( &api->Signal );
58  _Thread_Action_initialize( &api->Signal_action, _Signal_Action_handler );
59#if !defined(RTEMS_SMP)
60  created->task_variables = NULL;
61#endif
62
63  /*
64   * We know this is deprecated and don't want a warning on every BSP built.
65   */
66  #pragma GCC diagnostic push
67  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
68  if ( rtems_configuration_get_notepads_enabled() ) {
69    for (i=0; i < RTEMS_NUMBER_NOTEPADS; i++)
70      api->Notepads[i] = 0;
71  }
72  #pragma GCC diagnostic pop
73
74  return true;
75}
76
77/*
78 *  _RTEMS_tasks_Start_extension
79 *
80 *  This extension routine is invoked when a task is started for the
81 *  first time.
82 */
83
84static void _RTEMS_tasks_Start_extension(
85  Thread_Control *executing,
86  Thread_Control *started
87)
88{
89  RTEMS_API_Control *api;
90
91  api = started->API_Extensions[ THREAD_API_RTEMS ];
92
93  _Event_Initialize( &api->Event );
94  _Event_Initialize( &api->System_event );
95}
96
97static void _RTEMS_tasks_Delete_extension(
98  Thread_Control *executing,
99  Thread_Control *deleted
100)
101{
102  RTEMS_API_Control *api;
103
104  api = deleted->API_Extensions[ THREAD_API_RTEMS ];
105
106  _ASR_Destroy( &api->Signal );
107}
108
109static void _RTEMS_tasks_Terminate_extension(
110  Thread_Control *executing
111)
112{
113  /*
114   *  Free per task variable memory
115   *
116   *  Per Task Variables are only enabled in uniprocessor configurations.
117   */
118  #if !defined(RTEMS_SMP)
119    /*
120     * We know this is deprecated and don't want a warning on every BSP built.
121     */
122    #pragma GCC diagnostic push
123    #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
124    do {
125      rtems_task_variable_t *tvp, *next;
126
127      tvp = executing->task_variables;
128      executing->task_variables = NULL;
129      while (tvp) {
130        next = (rtems_task_variable_t *)tvp->next;
131        _RTEMS_Tasks_Invoke_task_variable_dtor( executing, tvp );
132        tvp = next;
133      }
134    } while (0);
135    #pragma GCC diagnostic pop
136  #endif
137
138  /*
139   *  Run all the key destructors
140   */
141  _POSIX_Keys_Run_destructors( executing );
142}
143
144#if !defined(RTEMS_SMP)
145/*
146 *  _RTEMS_tasks_Switch_extension
147 *
148 *  This extension routine is invoked at each context switch.
149 *
150 *  @note Since this only needs to address per-task variables, it is
151 *        disabled entirely for SMP configurations.
152 */
153static void _RTEMS_tasks_Switch_extension(
154  Thread_Control *executing,
155  Thread_Control *heir
156)
157{
158  rtems_task_variable_t *tvp;
159
160  /*
161   *  Per Task Variables are only enabled in uniprocessor configurations
162   */
163
164  tvp = executing->task_variables;
165  while (tvp) {
166    tvp->tval = *tvp->ptr;
167    *tvp->ptr = tvp->gval;
168    tvp = (rtems_task_variable_t *)tvp->next;
169  }
170
171  tvp = heir->task_variables;
172  while (tvp) {
173    tvp->gval = *tvp->ptr;
174    *tvp->ptr = tvp->tval;
175    tvp = (rtems_task_variable_t *)tvp->next;
176  }
177}
178#define RTEMS_TASKS_SWITCH_EXTENSION _RTEMS_tasks_Switch_extension
179#else
180#define RTEMS_TASKS_SWITCH_EXTENSION NULL
181#endif
182
183API_extensions_Control _RTEMS_tasks_API_extensions = {
184  #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
185    .predriver_hook = NULL,
186  #endif
187  .postdriver_hook = _RTEMS_tasks_Initialize_user_tasks
188};
189
190User_extensions_Control _RTEMS_tasks_User_extensions = {
191  { NULL, NULL },
192  { { NULL, NULL }, RTEMS_TASKS_SWITCH_EXTENSION },
193  { _RTEMS_tasks_Create_extension,            /* create */
194    _RTEMS_tasks_Start_extension,             /* start */
195    _RTEMS_tasks_Start_extension,             /* restart */
196    _RTEMS_tasks_Delete_extension,            /* delete */
197    RTEMS_TASKS_SWITCH_EXTENSION,             /* switch */
198    NULL,                                     /* begin */
199    NULL,                                     /* exitted */
200    NULL,                                     /* fatal */
201    _RTEMS_tasks_Terminate_extension          /* terminate */
202  }
203};
204
205void _RTEMS_tasks_Manager_initialization(void)
206{
207  _Objects_Initialize_information(
208    &_RTEMS_tasks_Information, /* object information table */
209    OBJECTS_CLASSIC_API,       /* object API */
210    OBJECTS_RTEMS_TASKS,       /* object class */
211    Configuration_RTEMS_API.maximum_tasks,
212                               /* maximum objects of this class */
213    _Thread_Control_size,      /* size of this object's control block */
214    false,                     /* true if the name is a string */
215    RTEMS_MAXIMUM_NAME_LENGTH  /* maximum length of an object name */
216#if defined(RTEMS_MULTIPROCESSING)
217    ,
218    true,                      /* true if this is a global object class */
219    NULL                       /* Proxy extraction support callout */
220#endif
221  );
222
223  /*
224   *  Add all the extensions for this API
225   */
226
227  _User_extensions_Add_API_set( &_RTEMS_tasks_User_extensions );
228
229  _API_extensions_Add( &_RTEMS_tasks_API_extensions );
230
231  /*
232   *  Register the MP Process Packet routine.
233   */
234
235#if defined(RTEMS_MULTIPROCESSING)
236  _MPCI_Register_packet_processor(
237    MP_PACKET_TASKS,
238    _RTEMS_tasks_MP_Process_packet
239  );
240#endif
241
242}
243
244void _RTEMS_tasks_Initialize_user_tasks( void )
245{
246  if ( _RTEMS_tasks_Initialize_user_tasks_p )
247    (*_RTEMS_tasks_Initialize_user_tasks_p)();
248}
Note: See TracBrowser for help on using the repository browser.