source: rtems/cpukit/rtems/include/rtems/rtems/tasks.h @ db80f11

4.104.115
Last change on this file since db80f11 was db80f11, checked in by Joel Sherrill <joel.sherrill@…>, on 12/17/08 at 20:21:40

2008-12-17 Joel Sherrill <joel.sherrill@…>

  • rtems/Makefile.am, rtems/include/rtems/rtems/attr.h, rtems/include/rtems/rtems/barrier.h, rtems/include/rtems/rtems/dpmem.h, rtems/include/rtems/rtems/intr.h, rtems/include/rtems/rtems/message.h, rtems/include/rtems/rtems/part.h, rtems/include/rtems/rtems/ratemon.h, rtems/include/rtems/rtems/region.h, rtems/include/rtems/rtems/sem.h, rtems/include/rtems/rtems/tasks.h, rtems/include/rtems/rtems/timer.h, rtems/src/barrier.c, rtems/src/dpmem.c, rtems/src/msg.c, rtems/src/part.c, rtems/src/ratemon.c, rtems/src/region.c, rtems/src/rtemstimer.c, rtems/src/sem.c, rtems/src/tasks.c, sapi/src/rtemsapi.c: Convert manager initialization routines to directly pull parameters from configuration table. Eliminate empty routines sportted.
  • rtems/src/intr.c: Removed.
  • Property mode set to 100644
File size: 13.6 KB
Line 
1/**
2 * @file rtems/rtems/tasks.h
3 *
4 *  This include file contains all constants and structures associated
5 *  with RTEMS tasks.  This manager provides a comprehensive set of directives
6 *  to create, delete, and administer tasks.
7 *
8 *  Directives provided are:
9 *
10 *     - create a task
11 *     - get an ID of a task
12 *     - start a task
13 *     - restart a task
14 *     - delete a task
15 *     - suspend a task
16 *     - resume a task
17 *     - set a task's priority
18 *     - change the current task's mode
19 *     - get a task notepad entry
20 *     - set a task notepad entry
21 *     - wake up after interval
22 *     - wake up when specified
23 */
24
25/*  COPYRIGHT (c) 1989-2008.
26 *  On-Line Applications Research Corporation (OAR).
27 *
28 *  The license and distribution terms for this file may be
29 *  found in the file LICENSE in this distribution or at
30 *  http://www.rtems.com/license/LICENSE.
31 *
32 *  $Id$
33 */
34
35#ifndef _RTEMS_RTEMS_TASKS_H
36#define _RTEMS_RTEMS_TASKS_H
37
38#include <rtems/score/object.h>
39#include <rtems/score/states.h>
40#include <rtems/score/thread.h>
41#include <rtems/rtems/types.h>
42#include <rtems/rtems/eventset.h>
43#include <rtems/rtems/asr.h>
44#include <rtems/rtems/attr.h>
45#include <rtems/rtems/status.h>
46
47/**
48 *  This constant is defined to extern most of the time when using
49 *  this header file.  However by defining it to nothing, the data
50 *  declared in this header file can be instantiated.  This is done
51 *  in a single per manager file.
52 */
53#ifndef RTEMS_TASKS_EXTERN
54#define RTEMS_TASKS_EXTERN extern
55#endif
56
57/**
58 *  @defgroup ClassicTasks Classic API Tasks
59 *
60 *  This encapsulates functionality which X XX
61 */
62/**@{*/
63
64#ifdef __cplusplus
65extern "C" {
66#endif
67
68/**
69 *  Constant to be used as the ID of current task
70 */
71#define RTEMS_SELF                OBJECTS_ID_OF_SELF
72
73/**
74 *  This constant is passed to the rtems_task_wake_after directive as the
75 *  interval when a task wishes to yield the CPU.
76 */
77#define RTEMS_YIELD_PROCESSOR WATCHDOG_NO_TIMEOUT
78
79/**
80 *  Define the type for an RTEMS API task priority.
81 */
82typedef Priority_Control rtems_task_priority;
83
84/**
85 *  This is the constant used with the rtems_task_set_priority
86 *  directive to indicate that the caller wants to obtain its
87 *  current priority rather than set it as the name of the
88 *  directive indicates.
89 */
90#define RTEMS_NO_PRIORITY           RTEMS_CURRENT_PRIORITY
91
92/**
93 *  This constant is the least valid value for a Classic API
94 *  task priority.
95 */
96#define RTEMS_MINIMUM_PRIORITY      (PRIORITY_MINIMUM + 1)
97
98/**
99 *  This constant is the maximum valid value for a Classic API
100 *  task priority.
101 *
102 *  @note This is actually the priority of the IDLE thread so
103 *        using this priority will result in having a task
104 *        which never executes.  This could be useful if you
105 *        want to ensure that a task does not executes during
106 *        certain operations such as a system mode change.
107 */
108#define RTEMS_MAXIMUM_PRIORITY      PRIORITY_MAXIMUM
109
110/**
111 *  The following constant is passed to rtems_task_set_priority when the
112 *  caller wants to obtain the current priority.
113 */
114#define RTEMS_CURRENT_PRIORITY      PRIORITY_MINIMUM
115
116/** This is used to indicate the lowest numbered notepad */
117#define RTEMS_NOTEPAD_FIRST 0
118/** This is used to indicate the notepad location 0. */
119#define RTEMS_NOTEPAD_0    0
120/** This is used to indicate the notepad location 1. */
121#define RTEMS_NOTEPAD_1    1
122/** This is used to indicate the notepad location 2. */
123#define RTEMS_NOTEPAD_2    2
124/** This is used to indicate the notepad location 3. */
125#define RTEMS_NOTEPAD_3    3
126/** This is used to indicate the notepad location 4. */
127#define RTEMS_NOTEPAD_4    4
128/** This is used to indicate the notepad location 5. */
129#define RTEMS_NOTEPAD_5    5
130/** This is used to indicate the notepad location 6. */
131#define RTEMS_NOTEPAD_6    6
132/** This is used to indicate the notepad location 7. */
133#define RTEMS_NOTEPAD_7    7
134/** This is used to indicate the notepad location 8. */
135#define RTEMS_NOTEPAD_8    8
136/** This is used to indicate the notepad location 9. */
137#define RTEMS_NOTEPAD_9    9
138/** This is used to indicate the notepad location 10. */
139#define RTEMS_NOTEPAD_10   10
140/** This is used to indicate the notepad location 11. */
141#define RTEMS_NOTEPAD_11   11
142/** This is used to indicate the notepad location 12. */
143#define RTEMS_NOTEPAD_12   12
144/** This is used to indicate the notepad location 13. */
145#define RTEMS_NOTEPAD_13   13
146/** This is used to indicate the notepad location 14. */
147#define RTEMS_NOTEPAD_14   14
148/** This is used to indicate the notepad location 15. */
149#define RTEMS_NOTEPAD_15   15
150/** This is used to indicate the highest numbered notepad. */
151#define RTEMS_NOTEPAD_LAST RTEMS_NOTEPAD_15
152
153/** This is used to indicate the number of notepads available. */
154#define RTEMS_NUMBER_NOTEPADS  (RTEMS_NOTEPAD_LAST+1)
155
156/**
157 *  External API name for Thread_Control
158 */
159typedef Thread_Control rtems_tcb;
160
161/**
162 *  The following defines the "return type" of an RTEMS task.
163 */
164typedef void rtems_task;
165
166/**
167 *  The following defines the argument to an RTEMS task.
168 */
169typedef Thread_Entry_numeric_type rtems_task_argument;
170
171/**
172 *  The following defines the type for the entry point of an RTEMS task.
173 */
174typedef rtems_task ( *rtems_task_entry )(
175                      rtems_task_argument
176                   );
177
178/**
179 *  The following records define the Initialization Tasks Table.
180 *  Each entry contains the information required by RTEMS to
181 *  create and start a user task automatically at executive
182 *  initialization time.
183 */
184typedef struct {
185  /** This is the Initialization Task's name. */
186  rtems_name            name;
187  /** This is the Initialization Task's stack size. */
188  size_t                stack_size;
189  /** This is the Initialization Task's priority. */
190  rtems_task_priority   initial_priority;
191  /** This is the Initialization Task's attributes. */
192  rtems_attribute       attribute_set;
193  /** This is the Initialization Task's entry point. */
194  rtems_task_entry      entry_point;
195  /** This is the Initialization Task's initial mode. */
196  rtems_mode            mode_set;
197  /** This is the Initialization Task's argument. */
198  rtems_task_argument   argument;
199} rtems_initialization_tasks_table;
200
201/**
202 *  This is the API specific information required by each thread for
203 *  the RTEMS API to function correctly.
204 *
205 *  @note Notepads must be the last entry in the structure and memory
206 *        will be taken away from this structure when allocated if
207 *        notespads are disabled by the application configuration.
208 */
209typedef struct {
210  /** This field contains the pending events for this task. */
211  rtems_event_set          pending_events;
212  /** This field contains the event wait condition for this task. */
213  rtems_event_set          event_condition;
214  /** This field contains the Classic API Signal information for this task. */
215  ASR_Information          Signal;
216  /**
217   *  This field contains the notepads for this task.
218   *
219   *  @note MUST BE LAST ENTRY.
220   */
221  uint32_t                 Notepads[ RTEMS_NUMBER_NOTEPADS ];
222}  RTEMS_API_Control;
223
224/**
225 *  The following instantiates the information control block used to
226 *  manage this class of objects.
227 */
228RTEMS_TASKS_EXTERN Objects_Information _RTEMS_tasks_Information;
229
230/**
231 *  When the user configures a set of Classic API initialization tasks,
232 *  This variable will point to the method used to initialize them.
233 * 
234 *  @note It is instantiated and initialized by confdefs.h based upon
235 *        application requirements.
236 */
237extern void (*_RTEMS_tasks_Initialize_user_tasks_p)(void);
238
239/**
240 *  @brief _RTEMS_tasks_Manager_initialization
241 *
242 *  This routine initializes all Task Manager related data structures.
243 */
244void _RTEMS_tasks_Manager_initialization(void);
245
246/**
247 *  @brief rtems_task_create
248 *
249 *  This routine implements the rtems_task_create directive.  The task
250 *  will have the name name.  The attribute_set can be used to indicate
251 *  that the task will be globally accessible or utilize floating point.
252 *  The task's stack will be stack_size bytes.   The task will begin
253 *  execution with initial_priority and initial_modes.  It returns the
254 *  id of the created task in ID.
255 */
256rtems_status_code rtems_task_create(
257  rtems_name           name,
258  rtems_task_priority  initial_priority,
259  size_t               stack_size,
260  rtems_mode           initial_modes,
261  rtems_attribute      attribute_set,
262  Objects_Id          *id
263);
264
265/**
266 *  @brief rtems_task_ident
267 *
268 *  This routine implements the rtems_task_ident directive.
269 *  This directive returns the task ID associated with name.
270 *  If more than one task is named name, then the task to
271 *  which the ID belongs is arbitrary.  node indicates the
272 *  extent of the search for the ID of the task named name.
273 *  The search can be limited to a particular node or allowed to
274 *  encompass all nodes.
275 */
276rtems_status_code rtems_task_ident(
277  rtems_name    name,
278  uint32_t      node,
279  Objects_Id   *id
280);
281
282/**
283 *  @brief rtems_task_delete
284 *
285 *  This routine implements the rtems_task_delete directive.  The
286 *  task indicated by ID is deleted.
287 */
288rtems_status_code rtems_task_delete(
289  Objects_Id id
290);
291
292/**
293 *  @brief rtems_task_get_note
294 *
295 *  This routine implements the rtems_task_get_note directive.  The
296 *  value of the indicated notepad for the task associated with ID
297 *  is returned in note.
298 */
299rtems_status_code rtems_task_get_note(
300  Objects_Id  id,
301  uint32_t    notepad,
302  uint32_t   *note
303);
304
305/**
306 *  @brief rtems_task_set_note
307 *
308 *  This routine implements the rtems_task_set_note directive.  The
309 *  value of the indicated notepad for the task associated with ID
310 *  is returned in note.
311 */
312rtems_status_code rtems_task_set_note(
313  Objects_Id id,
314  uint32_t   notepad,
315  uint32_t   note
316);
317
318/**
319 *  @brief rtems_task_mode
320 *
321 *  This routine implements the rtems_task_mode directive.  The current
322 *  values of the modes indicated by mask of the calling task are changed
323 *  to that indicated in mode_set.  The former mode of the task is
324 *  returned in mode_set.
325 */
326rtems_status_code rtems_task_mode(
327  rtems_mode  mode_set,
328  rtems_mode  mask,
329  rtems_mode *previous_mode_set
330);
331
332/**
333 *  @brief rtems_task_restart
334 *
335 *  This routine implements the rtems_task_restart directive.  The
336 *  task associated with ID is restarted at its initial entry
337 *  point with the new argument.
338 */
339rtems_status_code rtems_task_restart(
340  Objects_Id id,
341  uint32_t   arg
342);
343
344/**
345 *  @brief rtems_task_suspend
346 *
347 *  This routine implements the rtems_task_suspend directive.  The
348 *  SUSPENDED state is set for task associated with ID.
349 */
350rtems_status_code rtems_task_suspend(
351  Objects_Id id
352);
353
354/**
355 *  @brief rtems_task_resume
356 *
357 *  This routine implements the rtems_task_resume Directive.  The
358 *  SUSPENDED state is cleared for task associated with ID.
359 */
360rtems_status_code rtems_task_resume(
361  Objects_Id id
362);
363
364/**
365 *  @brief rtems_task_set_priority
366 *
367 *  This routine implements the rtems_task_set_priority directive.  The
368 *  current priority of the task associated with ID is set to
369 *  new_priority.  The former priority of that task is returned
370 *  in old_priority.
371 */
372rtems_status_code rtems_task_set_priority(
373  Objects_Id           id,
374  rtems_task_priority  new_priority,
375  rtems_task_priority *old_priority
376);
377
378/**
379 *  @brief rtems_task_start
380 *
381 *  This routine implements the rtems_task_start directive.  The
382 *  starting execution point of the task associated with ID is
383 *  set to entry_point with the initial argument.
384 */
385rtems_status_code rtems_task_start(
386  Objects_Id   id,
387  rtems_task_entry entry_point,
388  rtems_task_argument     argument
389);
390
391/**
392 *  @brief rtems_task_wake_when
393 *
394 *  This routine implements the rtems_task_wake_when directive.  The
395 *  calling task is blocked until the current time of day is
396 *  equal to that indicated by time_buffer.
397 */
398rtems_status_code rtems_task_wake_when(
399  rtems_time_of_day *time_buffer
400);
401
402/**
403 *  @brief rtems_task_wake_after
404 *
405 *  This routine implements the rtems_task_wake_after directive.  The
406 *  calling task is blocked until the indicated number of clock
407 *  ticks have occurred.
408 */
409rtems_status_code rtems_task_wake_after(
410  rtems_interval  ticks
411);
412
413/**
414 *  @brief rtems_task_is_suspended
415 
416 *  This directive returns a status indicating whether or not
417 *  the specified task is suspended.
418 */
419rtems_status_code rtems_task_is_suspended(
420  Objects_Id id
421);
422
423/**
424 *  @brief rtems_task_variable_add
425 *
426 *  This directive adds a per task variable.
427 */
428rtems_status_code rtems_task_variable_add(
429  rtems_id  tid,
430  void    **ptr,
431  void    (*dtor)(void *)
432);
433
434/**
435 *  @brief rtems_task_variable_get
436 *
437 *  This directive gets the value of a task variable.
438 */
439rtems_status_code rtems_task_variable_get(
440  rtems_id tid,
441  void **ptr,
442  void **result
443);
444
445/**
446 *  @brief rtems_task_variable_delete
447 *
448 *  This directive removes a per task variable.
449 */
450rtems_status_code rtems_task_variable_delete(
451  rtems_id  tid,
452  void    **ptr
453);
454
455/**
456 *  @brief rtems_task_self
457 *
458 *  This directive returns the ID of the currently executing task.
459 */
460rtems_id rtems_task_self(void);
461
462/**
463 *  @brief _RTEMS_tasks_Initialize_user_tasks
464 *
465 *  This routine creates and starts all configured user
466 *  initialzation threads.
467 *
468 *  Input parameters: NONE
469 *
470 *  Output parameters:  NONE
471 */
472void _RTEMS_tasks_Initialize_user_tasks( void );
473
474/**
475 *  @brief _RTEMS_Tasks_Invoke_task_variable_dtor(
476 *
477 *  This routine invokes the optional user provided destructor on the
478 *  task variable and frees the memory for the task variable.
479 *
480 *  Input parameters: NONE
481 *
482 *  Output parameters:  NONE
483 */
484void _RTEMS_Tasks_Invoke_task_variable_dtor(
485  Thread_Control        *the_thread,
486  rtems_task_variable_t *tvp
487);
488
489#ifndef __RTEMS_APPLICATION__
490#include <rtems/rtems/tasks.inl>
491#endif
492#if defined(RTEMS_MULTIPROCESSING)
493#include <rtems/rtems/taskmp.h>
494#endif
495
496#ifdef __cplusplus
497}
498#endif
499
500/**@}*/
501
502#endif
503/* end of include file */
Note: See TracBrowser for help on using the repository browser.