source: rtems/cpukit/rtems/include/rtems/rtems/tasks.h @ 166b02df

4.115
Last change on this file since 166b02df was 166b02df, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/05/11 at 08:49:06

2011-12-05 Ralf Corsépius <ralf.corsepius@…>

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