source: rtems/c/src/exec/rtems/include/rtems/rtems/tasks.h @ 95bb279

4.104.114.84.95
Last change on this file since 95bb279 was 95bb279, checked in by Joel Sherrill <joel.sherrill@…>, on 11/12/99 at 14:54:13

Used typedef so all "struct rtems_task_variable_t" uses are now
just "rtems_task_variable_t".

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