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

4.104.114.84.95
Last change on this file since fb24f698 was fb24f698, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/09/07 at 15:06:37

Use size_t for stack-sizes.

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