source: rtems-docs/c_user/task_manager.rst @ c29f5bc

4.115
Last change on this file since c29f5bc was c29f5bc, checked in by Joel Sherrill <joel@…>, on 11/01/16 at 21:05:08

c_user: Re-add task notepads for 4.11. Remove this patch after branching.

  • Property mode set to 100644
File size: 55.2 KB
Line 
1.. comment SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. COMMENT: COPYRIGHT (c) 1988-2008.
4.. COMMENT: On-Line Applications Research Corporation (OAR).
5.. COMMENT: All rights reserved.
6
7Task Manager
8############
9
10.. index:: tasks
11
12Introduction
13============
14
15The task manager provides a comprehensive set of directives to create, delete,
16and administer tasks.  The directives provided by the task manager are:
17
18- rtems_task_create_ - Create a task
19
20- rtems_task_ident_ - Get ID of a task
21
22- rtems_task_self_ - Obtain ID of caller
23
24- rtems_task_start_ - Start a task
25
26- rtems_task_restart_ - Restart a task
27
28- rtems_task_delete_ - Delete a task
29
30- rtems_task_suspend_ - Suspend a task
31
32- rtems_task_resume_ - Resume a task
33
34- rtems_task_is_suspended_ - Determine if a task is suspended
35
36- rtems_task_set_priority_ - Set task priority
37
38- rtems_task_mode_ - Change current task's mode
39
40- rtems_task_get_note_ - Get task notepad entry
41
42- rtems_task_set_note_ - Set task notepad entry
43
44- rtems_task_wake_after_ - Wake up after interval
45
46- rtems_task_wake_when_ - Wake up when specified
47
48- rtems_iterate_over_all_threads_ - Iterate Over Tasks
49
50- rtems_task_variable_add_ - Associate per task variable
51
52- rtems_task_variable_get_ - Obtain value of a a per task variable
53
54- rtems_task_variable_delete_ - Remove per task variable
55
56Background
57==========
58
59Task Definition
60---------------
61.. index:: task, definition
62
63Many definitions of a task have been proposed in computer literature.
64Unfortunately, none of these definitions encompasses all facets of the concept
65in a manner which is operating system independent.  Several of the more common
66definitions are provided to enable each user to select a definition which best
67matches their own experience and understanding of the task concept:
68
69- a "dispatchable" unit.
70
71- an entity to which the processor is allocated.
72
73- an atomic unit of a real-time, multiprocessor system.
74
75- single threads of execution which concurrently compete for resources.
76
77- a sequence of closely related computations which can execute concurrently
78  with other computational sequences.
79
80From RTEMS' perspective, a task is the smallest thread of execution which can
81compete on its own for system resources.  A task is manifested by the existence
82of a task control block (TCB).
83
84Task Control Block
85------------------
86
87The Task Control Block (TCB) is an RTEMS defined data structure which contains
88all the information that is pertinent to the execution of a task.  During
89system initialization, RTEMS reserves a TCB for each task configured.  A TCB is
90allocated upon creation of the task and is returned to the TCB free list upon
91deletion of the task.
92
93The TCB's elements are modified as a result of system calls made by the
94application in response to external and internal stimuli.  TCBs are the only
95RTEMS internal data structure that can be accessed by an application via user
96extension routines.  The TCB contains a task's name, ID, current priority,
97current and starting states, execution mode, TCB user extension pointer,
98scheduling control structures, as well as data required by a blocked task.
99
100A task's context is stored in the TCB when a task switch occurs.  When the task
101regains control of the processor, its context is restored from the TCB.  When a
102task is restarted, the initial state of the task is restored from the starting
103context area in the task's TCB.
104
105Task States
106-----------
107.. index:: task states
108
109A task may exist in one of the following five states:
110
111- *executing* - Currently scheduled to the CPU
112
113- *ready* - May be scheduled to the CPU
114
115- *blocked* - Unable to be scheduled to the CPU
116
117- *dormant* - Created task that is not started
118
119- *non-existent* - Uncreated or deleted task
120
121An active task may occupy the executing, ready, blocked or dormant state,
122otherwise the task is considered non-existent.  One or more tasks may be active
123in the system simultaneously.  Multiple tasks communicate, synchronize, and
124compete for system resources with each other via system calls.  The multiple
125tasks appear to execute in parallel, but actually each is dispatched to the CPU
126for periods of time determined by the RTEMS scheduling algorithm.  The
127scheduling of a task is based on its current state and priority.
128
129Task Priority
130-------------
131.. index:: task priority
132.. index:: priority, task
133.. index:: rtems_task_priority
134
135A task's priority determines its importance in relation to the other tasks
136executing on the same processor.  RTEMS supports 255 levels of priority ranging
137from 1 to 255.  The data type ``rtems_task_priority`` is used to store task
138priorities.
139
140Tasks of numerically smaller priority values are more important tasks than
141tasks of numerically larger priority values.  For example, a task at priority
142level 5 is of higher privilege than a task at priority level 10.  There is no
143limit to the number of tasks assigned to the same priority.
144
145Each task has a priority associated with it at all times.  The initial value of
146this priority is assigned at task creation time.  The priority of a task may be
147changed at any subsequent time.
148
149Priorities are used by the scheduler to determine which ready task will be
150allowed to execute.  In general, the higher the logical priority of a task, the
151more likely it is to receive processor execution time.
152
153Task Mode
154---------
155.. index:: task mode
156.. index:: rtems_task_mode
157
158A task's execution mode is a combination of the following four components:
159
160- preemption
161
162- ASR processing
163
164- timeslicing
165
166- interrupt level
167
168It is used to modify RTEMS' scheduling process and to alter the execution
169environment of the task.  The data type ``rtems_task_mode`` is used to manage
170the task execution mode.
171
172.. index:: preemption
173
174The preemption component allows a task to determine when control of the
175processor is relinquished.  If preemption is disabled (``RTEMS_NO_PREEMPT``),
176the task will retain control of the processor as long as it is in the executing
177state - even if a higher priority task is made ready.  If preemption is enabled
178(``RTEMS_PREEMPT``) and a higher priority task is made ready, then the
179processor will be taken away from the current task immediately and given to the
180higher priority task.
181
182.. index:: timeslicing
183
184The timeslicing component is used by the RTEMS scheduler to determine how the
185processor is allocated to tasks of equal priority.  If timeslicing is enabled
186(``RTEMS_TIMESLICE``), then RTEMS will limit the amount of time the task can
187execute before the processor is allocated to another ready task of equal
188priority. The length of the timeslice is application dependent and specified in
189the Configuration Table.  If timeslicing is disabled (``RTEMS_NO_TIMESLICE``),
190then the task will be allowed to execute until a task of higher priority is
191made ready.  If ``RTEMS_NO_PREEMPT`` is selected, then the timeslicing component
192is ignored by the scheduler.
193
194The asynchronous signal processing component is used to determine when received
195signals are to be processed by the task.  If signal processing is enabled
196(``RTEMS_ASR``), then signals sent to the task will be processed the next time
197the task executes.  If signal processing is disabled (``RTEMS_NO_ASR``), then
198all signals received by the task will remain posted until signal processing is
199enabled.  This component affects only tasks which have established a routine to
200process asynchronous signals.
201
202.. index:: interrupt level, task
203
204The interrupt level component is used to determine which interrupts will be
205enabled when the task is executing. ``RTEMS_INTERRUPT_LEVEL(n)`` specifies that
206the task will execute at interrupt level n.
207
208.. list-table::
209 :class: rtems-table
210
211 * - ``RTEMS_PREEMPT``
212   - enable preemption (default)
213 * - ``RTEMS_NO_PREEMPT``
214   - disable preemption
215 * - ``RTEMS_NO_TIMESLICE``
216   - disable timeslicing (default)
217 * - ``RTEMS_TIMESLICE``
218   - enable timeslicing
219 * - ``RTEMS_ASR``
220   - enable ASR processing (default)
221 * - ``RTEMS_NO_ASR``
222   - disable ASR processing
223 * - ``RTEMS_INTERRUPT_LEVEL(0)``
224   - enable all interrupts (default)
225 * - ``RTEMS_INTERRUPT_LEVEL(n)``
226   - execute at interrupt level n
227
228The set of default modes may be selected by specifying the
229``RTEMS_DEFAULT_MODES`` constant.
230
231Accessing Task Arguments
232------------------------
233.. index:: task arguments
234.. index:: task prototype
235
236All RTEMS tasks are invoked with a single argument which is specified when they
237are started or restarted.  The argument is commonly used to communicate startup
238information to the task.  The simplest manner in which to define a task which
239accesses it argument is:
240
241.. index:: rtems_task
242
243.. code-block:: c
244
245    rtems_task user_task(
246        rtems_task_argument argument
247    );
248
249Application tasks requiring more information may view this single argument as
250an index into an array of parameter blocks.
251
252Floating Point Considerations
253-----------------------------
254.. index:: floating point
255
256Creating a task with the ``RTEMS_FLOATING_POINT`` attribute flag results in
257additional memory being allocated for the TCB to store the state of the numeric
258coprocessor during task switches.  This additional memory is *NOT* allocated for
259``RTEMS_NO_FLOATING_POINT`` tasks. Saving and restoring the context of a
260``RTEMS_FLOATING_POINT`` task takes longer than that of a
261``RTEMS_NO_FLOATING_POINT`` task because of the relatively large amount of time
262required for the numeric coprocessor to save or restore its computational
263state.
264
265Since RTEMS was designed specifically for embedded military applications which
266are floating point intensive, the executive is optimized to avoid unnecessarily
267saving and restoring the state of the numeric coprocessor.  The state of the
268numeric coprocessor is only saved when a ``RTEMS_FLOATING_POINT`` task is
269dispatched and that task was not the last task to utilize the coprocessor.  In
270a system with only one ``RTEMS_FLOATING_POINT`` task, the state of the numeric
271coprocessor will never be saved or restored.
272
273Although the overhead imposed by ``RTEMS_FLOATING_POINT`` tasks is minimal,
274some applications may wish to completely avoid the overhead associated with
275``RTEMS_FLOATING_POINT`` tasks and still utilize a numeric coprocessor.  By
276preventing a task from being preempted while performing a sequence of floating
277point operations, a ``RTEMS_NO_FLOATING_POINT`` task can utilize the numeric
278coprocessor without incurring the overhead of a ``RTEMS_FLOATING_POINT``
279context switch.  This approach also avoids the allocation of a floating point
280context area.  However, if this approach is taken by the application designer,
281NO tasks should be created as ``RTEMS_FLOATING_POINT`` tasks.  Otherwise, the
282floating point context will not be correctly maintained because RTEMS assumes
283that the state of the numeric coprocessor will not be altered by
284``RTEMS_NO_FLOATING_POINT`` tasks.
285
286If the supported processor type does not have hardware floating capabilities or
287a standard numeric coprocessor, RTEMS will not provide built-in support for
288hardware floating point on that processor.  In this case, all tasks are
289considered ``RTEMS_NO_FLOATING_POINT`` whether created as
290``RTEMS_FLOATING_POINT`` or ``RTEMS_NO_FLOATING_POINT`` tasks.  A floating
291point emulation software library must be utilized for floating point
292operations.
293
294On some processors, it is possible to disable the floating point unit
295dynamically.  If this capability is supported by the target processor, then
296RTEMS will utilize this capability to enable the floating point unit only for
297tasks which are created with the ``RTEMS_FLOATING_POINT`` attribute.  The
298consequence of a ``RTEMS_NO_FLOATING_POINT`` task attempting to access the
299floating point unit is CPU dependent but will generally result in an exception
300condition.
301
302Per Task Variables
303------------------
304.. index:: per task variables
305
306Per task variables are deprecated, see the warning below.
307
308Per task variables are used to support global variables whose value may be
309unique to a task. After indicating that a variable should be treated as private
310(i.e. per-task) the task can access and modify the variable, but the
311modifications will not appear to other tasks, and other tasks' modifications to
312that variable will not affect the value seen by the task.  This is accomplished
313by saving and restoring the variable's value each time a task switch occurs to
314or from the calling task.
315
316The value seen by other tasks, including those which have not added the
317variable to their set and are thus accessing the variable as a common location
318shared among tasks, cannot be affected by a task once it has added a variable
319to its local set.  Changes made to the variable by other tasks will not affect
320the value seen by a task which has added the variable to its private set.
321
322This feature can be used when a routine is to be spawned repeatedly as several
323independent tasks.  Although each task will have its own stack, and thus
324separate stack variables, they will all share the same static and global
325variables.  To make a variable not shareable (i.e. a "global" variable that is
326specific to a single task), the tasks can call ``rtems_task_variable_add`` to
327make a separate copy of the variable for each task, but all at the same
328physical address.
329
330Task variables increase the context switch time to and from the tasks that own
331them so it is desirable to minimize the number of task variables.  One
332efficient method is to have a single task variable that is a pointer to a
333dynamically allocated structure containing the task's private "global" data.
334
335A critical point with per-task variables is that each task must separately
336request that the same global variable is per-task private.
337
338.. warning:
339
340  Per-Task variables are inherently broken on SMP systems. They only work
341  correctly when there is one task executing in the system and that task is the
342  logical owner of the value in the per-task variable's location. There is no
343  way for a single memory image to contain the correct value for each task
344  executing on each core. Consequently, per-task variables are disabled in SMP
345  configurations of RTEMS.  Instead the application developer should consider
346  the use of POSIX Keys or Thread Local Storage (TLS). POSIX Keys are not
347  enabled in all RTEMS configurations.
348
349Building a Task Attribute Set
350-----------------------------
351.. index:: task attributes, building
352
353In general, an attribute set is built by a bitwise OR of the desired
354components.  The set of valid task attribute components is listed below:
355
356.. list-table::
357 :class: rtems-table
358
359 * - ``RTEMS_NO_FLOATING_POINT``
360   - does not use coprocessor (default)
361 * - ``RTEMS_FLOATING_POINT``
362   - uses numeric coprocessor
363 * - ``RTEMS_LOCAL``
364   - local task (default)
365 * - ``RTEMS_GLOBAL``
366   - global task
367
368Attribute values are specifically designed to be mutually exclusive, therefore
369bitwise OR and addition operations are equivalent as long as each attribute
370appears exactly once in the component list.  A component listed as a default is
371not required to appear in the component list, although it is a good programming
372practice to specify default components.  If all defaults are desired, then
373``RTEMS_DEFAULT_ATTRIBUTES`` should be used.
374
375This example demonstrates the attribute_set parameter needed to create a local
376task which utilizes the numeric coprocessor.  The attribute_set parameter could
377be ``RTEMS_FLOATING_POINT`` or ``RTEMS_LOCAL | RTEMS_FLOATING_POINT``.  The
378attribute_set parameter can be set to ``RTEMS_FLOATING_POINT`` because
379``RTEMS_LOCAL`` is the default for all created tasks.  If the task were global
380and used the numeric coprocessor, then the attribute_set parameter would be
381``RTEMS_GLOBAL | RTEMS_FLOATING_POINT``.
382
383Building a Mode and Mask
384------------------------
385.. index:: task mode, building
386
387In general, a mode and its corresponding mask is built by a bitwise OR of the
388desired components.  The set of valid mode constants and each mode's
389corresponding mask constant is listed below:
390
391.. list-table::
392 :class: rtems-table
393
394 * - ``RTEMS_PREEMPT``
395   - is masked by ``RTEMS_PREEMPT_MASK`` and enables preemption
396 * - ``RTEMS_NO_PREEMPT``
397   - is masked by ``RTEMS_PREEMPT_MASK`` and disables preemption
398 * - ``RTEMS_NO_TIMESLICE``
399   - is masked by ``RTEMS_TIMESLICE_MASK`` and disables timeslicing
400 * - ``RTEMS_TIMESLICE``
401   - is masked by ``RTEMS_TIMESLICE_MASK`` and enables timeslicing
402 * - ``RTEMS_ASR``
403   - is masked by ``RTEMS_ASR_MASK`` and enables ASR processing
404 * - ``RTEMS_NO_ASR``
405   - is masked by ``RTEMS_ASR_MASK`` and disables ASR processing
406 * - ``RTEMS_INTERRUPT_LEVEL(0)``
407   - is masked by ``RTEMS_INTERRUPT_MASK`` and enables all interrupts
408 * - ``RTEMS_INTERRUPT_LEVEL(n)``
409   - is masked by ``RTEMS_INTERRUPT_MASK`` and sets interrupts level n
410
411Mode values are specifically designed to be mutually exclusive, therefore
412bitwise OR and addition operations are equivalent as long as each mode appears
413exactly once in the component list.  A mode component listed as a default is
414not required to appear in the mode component list, although it is a good
415programming practice to specify default components.  If all defaults are
416desired, the mode ``RTEMS_DEFAULT_MODES`` and the mask ``RTEMS_ALL_MODE_MASKS``
417should be used.
418
419The following example demonstrates the mode and mask parameters used with the
420``rtems_task_mode`` directive to place a task at interrupt level 3 and make it
421non-preemptible.  The mode should be set to ``RTEMS_INTERRUPT_LEVEL(3) |
422RTEMS_NO_PREEMPT`` to indicate the desired preemption mode and interrupt level,
423while the mask parameter should be set to ``RTEMS_INTERRUPT_MASK |
424RTEMS_NO_PREEMPT_MASK`` to indicate that the calling task's interrupt level and
425preemption mode are being altered.
426
427Operations
428==========
429
430Creating Tasks
431--------------
432
433The ``rtems_task_create`` directive creates a task by allocating a task control
434block, assigning the task a user-specified name, allocating it a stack and
435floating point context area, setting a user-specified initial priority, setting
436a user-specified initial mode, and assigning it a task ID.  Newly created tasks
437are initially placed in the dormant state.  All RTEMS tasks execute in the most
438privileged mode of the processor.
439
440Obtaining Task IDs
441------------------
442
443When a task is created, RTEMS generates a unique task ID and assigns it to the
444created task until it is deleted.  The task ID may be obtained by either of two
445methods.  First, as the result of an invocation of the ``rtems_task_create``
446directive, the task ID is stored in a user provided location.  Second, the task
447ID may be obtained later using the ``rtems_task_ident`` directive.  The task ID
448is used by other directives to manipulate this task.
449
450Starting and Restarting Tasks
451-----------------------------
452
453The ``rtems_task_start`` directive is used to place a dormant task in the ready
454state.  This enables the task to compete, based on its current priority, for
455the processor and other system resources.  Any actions, such as suspension or
456change of priority, performed on a task prior to starting it are nullified when
457the task is started.
458
459With the ``rtems_task_start`` directive the user specifies the task's starting
460address and argument.  The argument is used to communicate some startup
461information to the task.  As part of this directive, RTEMS initializes the
462task's stack based upon the task's initial execution mode and start address.
463The starting argument is passed to the task in accordance with the target
464processor's calling convention.
465
466The ``rtems_task_restart`` directive restarts a task at its initial starting
467address with its original priority and execution mode, but with a possibly
468different argument.  The new argument may be used to distinguish between the
469original invocation of the task and subsequent invocations.  The task's stack
470and control block are modified to reflect their original creation values.
471Although references to resources that have been requested are cleared,
472resources allocated by the task are NOT automatically returned to RTEMS.  A
473task cannot be restarted unless it has previously been started (i.e. dormant
474tasks cannot be restarted).  All restarted tasks are placed in the ready state.
475
476Suspending and Resuming Tasks
477-----------------------------
478
479The ``rtems_task_suspend`` directive is used to place either the caller or
480another task into a suspended state.  The task remains suspended until a
481``rtems_task_resume`` directive is issued.  This implies that a task may be
482suspended as well as blocked waiting either to acquire a resource or for the
483expiration of a timer.
484
485The ``rtems_task_resume`` directive is used to remove another task from the
486suspended state. If the task is not also blocked, resuming it will place it in
487the ready state, allowing it to once again compete for the processor and
488resources.  If the task was blocked as well as suspended, this directive clears
489the suspension and leaves the task in the blocked state.
490
491Suspending a task which is already suspended or resuming a task which is not
492suspended is considered an error.  The ``rtems_task_is_suspended`` can be used
493to determine if a task is currently suspended.
494
495Delaying the Currently Executing Task
496-------------------------------------
497
498The ``rtems_task_wake_after`` directive creates a sleep timer which allows a
499task to go to sleep for a specified interval.  The task is blocked until the
500delay interval has elapsed, at which time the task is unblocked.  A task
501calling the ``rtems_task_wake_after`` directive with a delay interval of
502``RTEMS_YIELD_PROCESSOR`` ticks will yield the processor to any other ready
503task of equal or greater priority and remain ready to execute.
504
505The ``rtems_task_wake_when`` directive creates a sleep timer which allows a
506task to go to sleep until a specified date and time.  The calling task is
507blocked until the specified date and time has occurred, at which time the task
508is unblocked.
509
510Changing Task Priority
511----------------------
512
513The ``rtems_task_set_priority`` directive is used to obtain or change the
514current priority of either the calling task or another task.  If the new
515priority requested is ``RTEMS_CURRENT_PRIORITY`` or the task's actual priority,
516then the current priority will be returned and the task's priority will remain
517unchanged.  If the task's priority is altered, then the task will be scheduled
518according to its new priority.
519
520The ``rtems_task_restart`` directive resets the priority of a task to its
521original value.
522
523Changing Task Mode
524------------------
525
526The ``rtems_task_mode`` directive is used to obtain or change the current
527execution mode of the calling task.  A task's execution mode is used to enable
528preemption, timeslicing, ASR processing, and to set the task's interrupt level.
529
530The ``rtems_task_restart`` directive resets the mode of a task to its original
531value.
532
533Notepad Locations
534-----------------
535
536RTEMS provides sixteen notepad locations for each task.  Each notepad
537location may contain a note consisting of four bytes of information.
538RTEMS provides two directives, ``rtems_task_set_note`` and
539``rtems_task_get_note``, that enable a user to access and change
540the notepad locations.  The ``rtems_task_set_note`` directive
541enables the user to set a task's notepad entry to a specified note.
542The ``rtems_task_get_note`` directive allows the user to obtain the note
543contained in any one of the sixteen notepads of a specified task.
544
545Task Deletion
546-------------
547
548RTEMS provides the ``rtems_task_delete`` directive to allow a task to delete
549itself or any other task.  This directive removes all RTEMS references to the
550task, frees the task's control block, removes it from resource wait queues, and
551deallocates its stack as well as the optional floating point context.  The
552task's name and ID become inactive at this time, and any subsequent references
553to either of them is invalid.  In fact, RTEMS may reuse the task ID for another
554task which is created later in the application.
555
556Unexpired delay timers (i.e. those used by ``rtems_task_wake_after`` and
557``rtems_task_wake_when``) and timeout timers associated with the task are
558automatically deleted, however, other resources dynamically allocated by the
559task are NOT automatically returned to RTEMS.  Therefore, before a task is
560deleted, all of its dynamically allocated resources should be deallocated by
561the user.  This may be accomplished by instructing the task to delete itself
562rather than directly deleting the task.  Other tasks may instruct a task to
563delete itself by sending a "delete self" message, event, or signal, or by
564restarting the task with special arguments which instruct the task to delete
565itself.
566
567Transition Advice for Obsolete Directives
568-----------------------------------------
569
570Notepads
571~~~~~~~~
572.. index:: rtems_task_get_note
573.. index:: rtems_task_set_note
574
575Task notepads and the associated directives ``rtems_task_get_note`` and
576``rtems_task_set_note`` were removed after the 4.11 Release Series. These were
577never thread-safe to access and subject to conflicting use of the notepad index
578by libraries which were designed independently.
579
580It is recommended that applications be modified to use services which are
581thread safe and not subject to issues with multiple applications conflicting
582over the key (e.g. notepad index) selection. For most applications, POSIX Keys
583should be used. These are available in all RTEMS build configurations. It is
584also possible that Thread Local Storage is an option for some use cases.
585
586Directives
587==========
588
589This section details the task manager's directives.  A subsection is dedicated
590to each of this manager's directives and describes the calling sequence,
591related constants, usage, and status codes.
592
593.. _rtems_task_create:
594
595TASK_CREATE - Create a task
596---------------------------
597.. index:: create a task
598
599**CALLING SEQUENCE:**
600
601.. index:: rtems_task_create
602
603.. code-block:: c
604
605    rtems_status_code rtems_task_create(
606        rtems_name           name,
607        rtems_task_priority  initial_priority,
608        size_t               stack_size,
609        rtems_mode           initial_modes,
610        rtems_attribute      attribute_set,
611        rtems_id            *id
612    );
613
614**DIRECTIVE STATUS CODES:**
615
616.. list-table::
617 :class: rtems-table
618
619 * - ``RTEMS_SUCCESSFUL``
620   - task created successfully
621 * - ``RTEMS_INVALID_ADDRESS``
622   - ``id`` is NULL
623 * - ``RTEMS_INVALID_NAME``
624   - invalid task name
625 * - ``RTEMS_INVALID_PRIORITY``
626   - invalid task priority
627 * - ``RTEMS_MP_NOT_CONFIGURED``
628   - multiprocessing not configured
629 * - ``RTEMS_TOO_MANY``
630   - too many tasks created
631 * - ``RTEMS_UNSATISFIED``
632   - not enough memory for stack/FP context
633 * - ``RTEMS_TOO_MANY``
634   - too many global objects
635
636**DESCRIPTION:**
637
638This directive creates a task which resides on the local node.  It allocates
639and initializes a TCB, a stack, and an optional floating point context area.
640The mode parameter contains values which sets the task's initial execution
641mode.  The ``RTEMS_FLOATING_POINT`` attribute should be specified if the
642created task is to use a numeric coprocessor.  For performance reasons, it is
643recommended that tasks not using the numeric coprocessor should specify the
644``RTEMS_NO_FLOATING_POINT`` attribute.  If the ``RTEMS_GLOBAL`` attribute is
645specified, the task can be accessed from remote nodes.  The task id, returned
646in id, is used in other task related directives to access the task.  When
647created, a task is placed in the dormant state and can only be made ready to
648execute using the directive ``rtems_task_start``.
649
650**NOTES:**
651
652This directive will not cause the calling task to be preempted.
653
654Valid task priorities range from a high of 1 to a low of 255.
655
656If the requested stack size is less than the configured minimum stack size,
657then RTEMS will use the configured minimum as the stack size for this task.  In
658addition to being able to specify the task stack size as a integer, there are
659two constants which may be specified:
660
661``RTEMS_MINIMUM_STACK_SIZE``
662  The minimum stack size *RECOMMENDED* for use on this processor.  This value
663  is selected by the RTEMS developers conservatively to minimize the risk of
664  blown stacks for most user applications.  Using this constant when specifying
665  the task stack size, indicates that the stack size will be at least
666  ``RTEMS_MINIMUM_STACK_SIZE`` bytes in size.  If the user configured minimum
667  stack size is larger than the recommended minimum, then it will be used.
668
669``RTEMS_CONFIGURED_MINIMUM_STACK_SIZE``
670  Indicates this task is to be created with a stack size of the minimum stack
671  size that was configured by the application.  If not explicitly configured by
672  the application, the default configured minimum stack size is the processor
673  dependent value ``RTEMS_MINIMUM_STACK_SIZE``.  Since this uses the configured
674  minimum stack size value, you may get a stack size that is smaller or larger
675  than the recommended minimum.  This can be used to provide large stacks for
676  all tasks on complex applications or small stacks on applications that are
677  trying to conserve memory.
678
679Application developers should consider the stack usage of the device drivers
680when calculating the stack size required for tasks which utilize the driver.
681
682The following task attribute constants are defined by RTEMS:
683
684.. list-table::
685 :class: rtems-table
686
687 * - ``RTEMS_NO_FLOATING_POINT``
688   - does not use coprocessor (default)
689 * - ``RTEMS_FLOATING_POINT``
690   - uses numeric coprocessor
691 * - ``RTEMS_LOCAL``
692   - local task (default)
693 * - ``RTEMS_GLOBAL``
694   - global task
695
696The following task mode constants are defined by RTEMS:
697
698.. list-table::
699 :class: rtems-table
700
701 * - ``RTEMS_PREEMPT``
702   - enable preemption (default)
703 * - ``RTEMS_NO_PREEMPT``
704   - disable preemption
705 * - ``RTEMS_NO_TIMESLICE``
706   - disable timeslicing (default)
707 * - ``RTEMS_TIMESLICE``
708   - enable timeslicing
709 * - ``RTEMS_ASR``
710   - enable ASR processing (default)
711 * - ``RTEMS_NO_ASR``
712   - disable ASR processing
713 * - ``RTEMS_INTERRUPT_LEVEL(0)``
714   - enable all interrupts (default)
715 * - ``RTEMS_INTERRUPT_LEVEL(n)``
716   - execute at interrupt level n
717
718The interrupt level portion of the task execution mode supports a maximum of
719256 interrupt levels.  These levels are mapped onto the interrupt levels
720actually supported by the target processor in a processor dependent fashion.
721
722Tasks should not be made global unless remote tasks must interact with them.
723This avoids the system overhead incurred by the creation of a global task.
724When a global task is created, the task's name and id must be transmitted to
725every node in the system for insertion in the local copy of the global object
726table.
727
728The total number of global objects, including tasks, is limited by the
729maximum_global_objects field in the Configuration Table.
730
731.. _rtems_task_ident:
732
733TASK_IDENT - Get ID of a task
734-----------------------------
735.. index:: get ID of a task
736
737**CALLING SEQUENCE:**
738
739.. index:: rtems_task_ident
740
741.. code-block:: c
742
743    rtems_status_code rtems_task_ident(
744        rtems_name  name,
745        uint32_t    node,
746        rtems_id   *id
747    );
748
749**DIRECTIVE STATUS CODES:**
750
751.. list-table::
752 :class: rtems-table
753
754 * - ``RTEMS_SUCCESSFUL``
755   - task identified successfully
756 * - ``RTEMS_INVALID_ADDRESS``
757   - ``id`` is NULL
758 * - ``RTEMS_INVALID_NAME``
759   - invalid task name
760 * - ``RTEMS_INVALID_NODE``
761   - invalid node id
762
763**DESCRIPTION:**
764
765This directive obtains the task id associated with the task name specified in
766name.  A task may obtain its own id by specifying ``RTEMS_SELF`` or its own
767task name in name.  If the task name is not unique, then the task id returned
768will match one of the tasks with that name.  However, this task id is not
769guaranteed to correspond to the desired task.  The task id, returned in id, is
770used in other task related directives to access the task.
771
772**NOTES:**
773
774This directive will not cause the running task to be preempted.
775
776If node is ``RTEMS_SEARCH_ALL_NODES``, all nodes are searched with the local
777node being searched first.  All other nodes are searched with the lowest
778numbered node searched first.
779
780If node is a valid node number which does not represent the local node, then
781only the tasks exported by the designated node are searched.
782
783This directive does not generate activity on remote nodes.  It accesses only
784the local copy of the global object table.
785
786.. _rtems_task_self:
787
788TASK_SELF - Obtain ID of caller
789-------------------------------
790.. index:: obtain ID of caller
791
792**CALLING SEQUENCE:**
793
794.. index:: rtems_task_self
795
796.. code-block:: c
797
798    rtems_id rtems_task_self(void);
799
800**DIRECTIVE STATUS CODES:**
801
802Returns the object Id of the calling task.
803
804**DESCRIPTION:**
805
806This directive returns the Id of the calling task.
807
808**NOTES:**
809
810If called from an interrupt service routine, this directive will return the Id
811of the interrupted task.
812
813.. _rtems_task_start:
814
815TASK_START - Start a task
816-------------------------
817.. index:: starting a task
818
819**CALLING SEQUENCE:**
820
821.. index:: rtems_task_start
822
823.. code-block:: c
824
825    rtems_status_code rtems_task_start(
826        rtems_id            id,
827        rtems_task_entry    entry_point,
828        rtems_task_argument argument
829    );
830
831**DIRECTIVE STATUS CODES:**
832
833.. list-table::
834 :class: rtems-table
835
836 * - ``RTEMS_SUCCESSFUL``
837   - ask started successfully
838 * - ``RTEMS_INVALID_ADDRESS``
839   - invalid task entry point
840 * - ``RTEMS_INVALID_ID``
841   - invalid task id
842 * - ``RTEMS_INCORRECT_STATE``
843   - task not in the dormant state
844 * - ``RTEMS_ILLEGAL_ON_REMOTE_OBJECT``
845   - cannot start remote task
846
847**DESCRIPTION:**
848
849This directive readies the task, specified by ``id``, for execution based on
850the priority and execution mode specified when the task was created.  The
851starting address of the task is given in ``entry_point``.  The task's starting
852argument is contained in argument.  This argument can be a single value or used
853as an index into an array of parameter blocks.  The type of this numeric
854argument is an unsigned integer type with the property that any valid pointer
855to void can be converted to this type and then converted back to a pointer to
856void.  The result will compare equal to the original pointer.
857
858**NOTES:**
859
860The calling task will be preempted if its preemption mode is enabled and the
861task being started has a higher priority.
862
863Any actions performed on a dormant task such as suspension or change of
864priority are nullified when the task is initiated via the ``rtems_task_start``
865directive.
866
867.. _rtems_task_restart:
868
869TASK_RESTART - Restart a task
870-----------------------------
871.. index:: restarting a task
872
873**CALLING SEQUENCE:**
874
875.. index:: rtems_task_restart
876
877.. code-block:: c
878
879    rtems_status_code rtems_task_restart(
880       rtems_id            id,
881       rtems_task_argument argument
882    );
883
884**DIRECTIVE STATUS CODES:**
885
886.. list-table::
887 :class: rtems-table
888
889 * - ``RTEMS_SUCCESSFUL``
890   - task restarted successfully
891 * - ``RTEMS_INVALID_ID``
892   - task id invalid
893 * - ``RTEMS_INCORRECT_STATE``
894   - task never started
895 * - ``RTEMS_ILLEGAL_ON_REMOTE_OBJECT``
896   - cannot restart remote task
897
898**DESCRIPTION:**
899
900This directive resets the task specified by id to begin execution at its
901original starting address.  The task's priority and execution mode are set to
902the original creation values.  If the task is currently blocked, RTEMS
903automatically makes the task ready.  A task can be restarted from any state,
904except the dormant state.
905
906The task's starting argument is contained in argument.  This argument can be a
907single value or an index into an array of parameter blocks.  The type of this
908numeric argument is an unsigned integer type with the property that any valid
909pointer to void can be converted to this type and then converted back to a
910pointer to void.  The result will compare equal to the original pointer.  This
911new argument may be used to distinguish between the initial
912``rtems_task_start`` of the task and any ensuing calls to
913``rtems_task_restart`` of the task.  This can be beneficial in deleting a task.
914Instead of deleting a task using the ``rtems_task_delete`` directive, a task
915can delete another task by restarting that task, and allowing that task to
916release resources back to RTEMS and then delete itself.
917
918**NOTES:**
919
920If id is ``RTEMS_SELF``, the calling task will be restarted and will not return
921from this directive.
922
923The calling task will be preempted if its preemption mode is enabled and the
924task being restarted has a higher priority.
925
926The task must reside on the local node, even if the task was created with the
927``RTEMS_GLOBAL`` option.
928
929.. _rtems_task_delete:
930
931TASK_DELETE - Delete a task
932---------------------------
933.. index:: deleting a task
934
935**CALLING SEQUENCE:**
936
937.. index:: rtems_task_delete
938
939.. code-block:: c
940
941    rtems_status_code rtems_task_delete(
942        rtems_id id
943    );
944
945**DIRECTIVE STATUS CODES:**
946
947.. list-table::
948 :class: rtems-table
949
950 * - ``RTEMS_SUCCESSFUL``
951   - task deleted successfully
952 * - ``RTEMS_INVALID_ID``
953   - task id invalid
954 * - ``RTEMS_ILLEGAL_ON_REMOTE_OBJECT``
955   - cannot restart remote task
956
957**DESCRIPTION:**
958
959This directive deletes a task, either the calling task or another task, as
960specified by id.  RTEMS stops the execution of the task and reclaims the stack
961memory, any allocated delay or timeout timers, the TCB, and, if the task is
962``RTEMS_FLOATING_POINT``, its floating point context area.  RTEMS does not
963reclaim the following resources: region segments, partition buffers,
964semaphores, timers, or rate monotonic periods.
965
966**NOTES:**
967
968A task is responsible for releasing its resources back to RTEMS before
969deletion.  To insure proper deallocation of resources, a task should not be
970deleted unless it is unable to execute or does not hold any RTEMS resources.
971If a task holds RTEMS resources, the task should be allowed to deallocate its
972resources before deletion.  A task can be directed to release its resources and
973delete itself by restarting it with a special argument or by sending it a
974message, an event, or a signal.
975
976Deletion of the current task (``RTEMS_SELF``) will force RTEMS to select
977another task to execute.
978
979When a global task is deleted, the task id must be transmitted to every node in
980the system for deletion from the local copy of the global object table.
981
982The task must reside on the local node, even if the task was created with the
983``RTEMS_GLOBAL`` option.
984
985.. _rtems_task_suspend:
986
987TASK_SUSPEND - Suspend a task
988-----------------------------
989.. index:: suspending a task
990
991**CALLING SEQUENCE:**
992
993.. index:: rtems_task_suspend
994
995.. code-block:: c
996
997    rtems_status_code rtems_task_suspend(
998        rtems_id id
999    );
1000
1001**DIRECTIVE STATUS CODES:**
1002
1003.. list-table::
1004 :class: rtems-table
1005
1006 * - ``RTEMS_SUCCESSFUL``
1007   - task suspended successfully
1008 * - ``RTEMS_INVALID_ID``
1009   - task id invalid
1010 * - ``RTEMS_ALREADY_SUSPENDED``
1011   - task already suspended
1012
1013**DESCRIPTION:**
1014
1015This directive suspends the task specified by id from further execution by
1016placing it in the suspended state.  This state is additive to any other blocked
1017state that the task may already be in.  The task will not execute again until
1018another task issues the ``rtems_task_resume`` directive for this task and any
1019blocked state has been removed.
1020
1021**NOTES:**
1022
1023The requesting task can suspend itself by specifying ``RTEMS_SELF`` as id.  In
1024this case, the task will be suspended and a successful return code will be
1025returned when the task is resumed.
1026
1027Suspending a global task which does not reside on the local node will generate
1028a request to the remote node to suspend the specified task.
1029
1030If the task specified by id is already suspended, then the
1031``RTEMS_ALREADY_SUSPENDED`` status code is returned.
1032
1033.. _rtems_task_resume:
1034
1035TASK_RESUME - Resume a task
1036---------------------------
1037.. index:: resuming a task
1038
1039**CALLING SEQUENCE:**
1040
1041.. index:: rtems_task_resume
1042
1043.. code-block:: c
1044
1045    rtems_status_code rtems_task_resume(
1046        rtems_id id
1047    );
1048
1049**DIRECTIVE STATUS CODES:**
1050
1051.. list-table::
1052 :class: rtems-table
1053
1054 * - ``RTEMS_SUCCESSFUL``
1055   - task resumed successfully
1056 * - ``RTEMS_INVALID_ID``
1057   - task id invalid
1058 * - ``RTEMS_INCORRECT_STATE``
1059   - task not suspended
1060
1061**DESCRIPTION:**
1062
1063This directive removes the task specified by id from the suspended state.  If
1064the task is in the ready state after the suspension is removed, then it will be
1065scheduled to run.  If the task is still in a blocked state after the suspension
1066is removed, then it will remain in that blocked state.
1067
1068**NOTES:**
1069
1070The running task may be preempted if its preemption mode is enabled and the
1071local task being resumed has a higher priority.
1072
1073Resuming a global task which does not reside on the local node will generate a
1074request to the remote node to resume the specified task.
1075
1076If the task specified by id is not suspended, then the
1077``RTEMS_INCORRECT_STATE`` status code is returned.
1078
1079.. _rtems_task_is_suspended:
1080
1081TASK_IS_SUSPENDED - Determine if a task is Suspended
1082----------------------------------------------------
1083.. index:: is task suspended
1084
1085**CALLING SEQUENCE:**
1086
1087.. index:: rtems_task_is_suspended
1088
1089.. code-block:: c
1090
1091    rtems_status_code rtems_task_is_suspended(
1092        rtems_id id
1093    );
1094
1095**DIRECTIVE STATUS CODES:**
1096
1097.. list-table::
1098 :class: rtems-table
1099
1100 * - ``RTEMS_SUCCESSFUL``
1101   - task is NOT suspended
1102 * - ``RTEMS_ALREADY_SUSPENDED``
1103   - task is currently suspended
1104 * - ``RTEMS_INVALID_ID``
1105   - task id invalid
1106 * - ``RTEMS_ILLEGAL_ON_REMOTE_OBJECT``
1107   - not supported on remote tasks
1108
1109**DESCRIPTION:**
1110
1111This directive returns a status code indicating whether or not the specified
1112task is currently suspended.
1113
1114**NOTES:**
1115
1116This operation is not currently supported on remote tasks.
1117
1118.. _rtems_task_set_priority:
1119
1120TASK_SET_PRIORITY - Set task priority
1121-------------------------------------
1122.. index:: rtems_task_set_priority
1123.. index:: current task priority
1124.. index:: set task priority
1125.. index:: get task priority
1126.. index:: obtain task priority
1127
1128**CALLING SEQUENCE:**
1129
1130.. code-block:: c
1131
1132    rtems_status_code rtems_task_set_priority(
1133        rtems_id             id,
1134        rtems_task_priority  new_priority,
1135        rtems_task_priority *old_priority
1136    );
1137
1138**DIRECTIVE STATUS CODES:**
1139
1140.. list-table::
1141 :class: rtems-table
1142
1143 * - ``RTEMS_SUCCESSFUL``
1144   - task priority set successfully
1145 * - ``RTEMS_INVALID_ID``
1146   - invalid task id
1147 * - ``RTEMS_INVALID_ADDRESS``
1148   - invalid return argument pointer
1149 * - ``RTEMS_INVALID_PRIORITY``
1150   - invalid task priority
1151
1152**DESCRIPTION:**
1153
1154This directive manipulates the priority of the task specified by id.  An id of
1155``RTEMS_SELF`` is used to indicate the calling task.  When new_priority is not
1156equal to ``RTEMS_CURRENT_PRIORITY``, the specified task's previous priority is
1157returned in old_priority.  When new_priority is ``RTEMS_CURRENT_PRIORITY``, the
1158specified task's current priority is returned in old_priority.  Valid
1159priorities range from a high of 1 to a low of 255.
1160
1161**NOTES:**
1162
1163The calling task may be preempted if its preemption mode is enabled and it
1164lowers its own priority or raises another task's priority.
1165
1166In case the new priority equals the current priority of the task, then nothing
1167happens.
1168
1169Setting the priority of a global task which does not reside on the local node
1170will generate a request to the remote node to change the priority of the
1171specified task.
1172
1173If the task specified by id is currently holding any binary semaphores which
1174use the priority inheritance algorithm, then the task's priority cannot be
1175lowered immediately.  If the task's priority were lowered immediately, then
1176priority inversion results.  The requested lowering of the task's priority will
1177occur when the task has released all priority inheritance binary semaphores.
1178The task's priority can be increased regardless of the task's use of priority
1179inheritance binary semaphores.
1180
1181.. _rtems_task_mode:
1182
1183TASK_MODE - Change the current task mode
1184----------------------------------------
1185.. index:: current task mode
1186.. index:: set task mode
1187.. index:: get task mode
1188.. index:: set task preemption mode
1189.. index:: get task preemption mode
1190.. index:: obtain task mode
1191
1192**CALLING SEQUENCE:**
1193
1194.. index:: rtems_task_mode
1195
1196.. code-block:: c
1197
1198    rtems_status_code rtems_task_mode(
1199        rtems_mode  mode_set,
1200        rtems_mode  mask,
1201        rtems_mode *previous_mode_set
1202    );
1203
1204**DIRECTIVE STATUS CODES:**
1205
1206.. list-table::
1207 :class: rtems-table
1208
1209 * - ``RTEMS_SUCCESSFUL``
1210   - task mode set successfully
1211 * - ``RTEMS_INVALID_ADDRESS``
1212   - ``previous_mode_set`` is NULL
1213
1214**DESCRIPTION:**
1215
1216This directive manipulates the execution mode of the calling task.  A task's
1217execution mode enables and disables preemption, timeslicing, asynchronous
1218signal processing, as well as specifying the current interrupt level.  To
1219modify an execution mode, the mode class(es) to be changed must be specified in
1220the mask parameter and the desired mode(s) must be specified in the mode
1221parameter.
1222
1223**NOTES:**
1224
1225The calling task will be preempted if it enables preemption and a higher
1226priority task is ready to run.
1227
1228Enabling timeslicing has no effect if preemption is disabled.  For a task to be
1229timesliced, that task must have both preemption and timeslicing enabled.
1230
1231A task can obtain its current execution mode, without modifying it, by calling
1232this directive with a mask value of ``RTEMS_CURRENT_MODE``.
1233
1234To temporarily disable the processing of a valid ASR, a task should call this
1235directive with the ``RTEMS_NO_ASR`` indicator specified in mode.
1236
1237The set of task mode constants and each mode's corresponding mask constant is
1238provided in the following table:
1239
1240.. list-table::
1241 :class: rtems-table
1242
1243 * - ``RTEMS_PREEMPT``
1244   - is masked by ``RTEMS_PREEMPT_MASK`` and enables preemption
1245 * - ``RTEMS_NO_PREEMPT``
1246   - is masked by ``RTEMS_PREEMPT_MASK`` and disables preemption
1247 * - ``RTEMS_NO_TIMESLICE``
1248   - is masked by ``RTEMS_TIMESLICE_MASK`` and disables timeslicing
1249 * - ``RTEMS_TIMESLICE``
1250   - is masked by ``RTEMS_TIMESLICE_MASK`` and enables timeslicing
1251 * - ``RTEMS_ASR``
1252   - is masked by ``RTEMS_ASR_MASK`` and enables ASR processing
1253 * - ``RTEMS_NO_ASR``
1254   - is masked by ``RTEMS_ASR_MASK`` and disables ASR processing
1255 * - ``RTEMS_INTERRUPT_LEVEL(0)``
1256   - is masked by ``RTEMS_INTERRUPT_MASK`` and enables all interrupts
1257 * - ``RTEMS_INTERRUPT_LEVEL(n)``
1258   - is masked by ``RTEMS_INTERRUPT_MASK`` and sets interrupts level n
1259
1260.. _rtems_task_get_note:
1261
1262TASK_GET_NOTE - Get task notepad entry
1263--------------------------------------
1264.. index:: get task notepad entry
1265
1266**CALLING SEQUENCE:**
1267
1268.. index:: rtems_task_get_note
1269
1270.. code-block:: c
1271
1272    rtems_status_code rtems_task_get_note(
1273      rtems_id  id,
1274      uint32_t  notepad,
1275      uint32_t *note
1276    );
1277
1278**DIRECTIVE STATUS CODES:**
1279
1280.. list-table::
1281 :class: rtems-table
1282
1283 * - ``RTEMS_SUCCESSFUL``
1284   - note value obtained successfully
1285 * - ``RTEMS_INVALID_ADDRESS``
1286   - ``note`` parameter is NULL
1287 * - ``RTEMS_INVALID_ID``
1288   - invalid task id
1289 * - ``RTEMS_INVALID_NUMBER``
1290   - invalid notepad location
1291
1292**DESCRIPTION:**
1293
1294This directive returns the note contained in the notepad location of
1295the task specified by id.
1296
1297**NOTES:**
1298
1299This directive will not cause the running task to be preempted.
1300
1301If id is set to ``RTEMS_SELF``, the calling task accesses its own notepad.
1302
1303The sixteen notepad locations can be accessed using the constants
1304``RTEMS_NOTEPAD_0`` through ``RTEMS_NOTEPAD_15``.
1305
1306Getting a note of a global task which does not reside on the
1307local node will generate a request to the remote node to obtain
1308the notepad entry of the specified task.
1309
1310.. _rtems_task_set_note:
1311
1312TASK_SET_NOTE - Set task notepad entry
1313--------------------------------------
1314.. index:: set task notepad entry
1315
1316**CALLING SEQUENCE:**
1317
1318.. index:: rtems_task_set_note
1319
1320.. code-block:: c
1321
1322    rtems_status_code rtems_task_set_note(
1323      rtems_id  id,
1324      uint32_t  notepad,
1325      uint32_t  note
1326    );
1327
1328**DIRECTIVE STATUS CODES:**
1329
1330.. list-table::
1331 :class: rtems-table
1332
1333 * - ``RTEMS_SUCCESSFUL``
1334   - note set successfully
1335 * - ``RTEMS_INVALID_ID``
1336   - invalid task id
1337 * - ``RTEMS_INVALID_NUMBER``
1338   - invalid notepad location
1339
1340**DESCRIPTION:**
1341
1342This directive sets the notepad entry for the task specified by
1343id to the value note.
1344
1345**NOTES:**
1346
1347If ``id`` is set to ``RTEMS_SELF``, the calling task accesses its own notepad.
1348
1349This directive will not cause the running task to be preempted.
1350
1351The sixteen notepad locations can be accessed using the constants
1352``RTEMS_NOTEPAD_0`` through ``RTEMS_NOTEPAD_15``.
1353
1354Setting a note of a global task which does not reside on the
1355local node will generate a request to the remote node to set
1356the notepad entry of the specified task.
1357
1358.. _rtems_task_wake_after:
1359
1360TASK_WAKE_AFTER - Wake up after interval
1361----------------------------------------
1362.. index:: delay a task for an interval
1363.. index:: wake up after an interval
1364
1365**CALLING SEQUENCE:**
1366
1367.. index:: rtems_task_wake_after
1368
1369.. code-block:: c
1370
1371    rtems_status_code rtems_task_wake_after(
1372        rtems_interval ticks
1373    );
1374
1375**DIRECTIVE STATUS CODES:**
1376
1377.. list-table::
1378 :class: rtems-table
1379
1380 * - ``RTEMS_SUCCESSFUL``
1381   - always successful
1382
1383**DESCRIPTION:**
1384
1385This directive blocks the calling task for the specified number of system clock
1386ticks.  When the requested interval has elapsed, the task is made ready.  The
1387``rtems_clock_tick`` directive automatically updates the delay period.
1388
1389**NOTES:**
1390
1391Setting the system date and time with the ``rtems_clock_set`` directive has no
1392effect on a ``rtems_task_wake_after`` blocked task.
1393
1394A task may give up the processor and remain in the ready state by specifying a
1395value of ``RTEMS_YIELD_PROCESSOR`` in ticks.
1396
1397The maximum timer interval that can be specified is the maximum value which can
1398be represented by the uint32_t type.
1399
1400A clock tick is required to support the functionality of this directive.
1401
1402.. _rtems_task_wake_when:
1403
1404TASK_WAKE_WHEN - Wake up when specified
1405---------------------------------------
1406.. index:: delay a task until a wall time
1407.. index:: wake up at a wall time
1408
1409**CALLING SEQUENCE:**
1410
1411.. index:: rtems_task_wake_when
1412
1413.. code-block:: c
1414
1415    rtems_status_code rtems_task_wake_when(
1416        rtems_time_of_day *time_buffer
1417    );
1418
1419**DIRECTIVE STATUS CODES:**
1420
1421.. list-table::
1422 :class: rtems-table
1423
1424 * - ``RTEMS_SUCCESSFUL``
1425   - awakened at date/time successfully
1426 * - ``RTEMS_INVALID_ADDRESS``
1427   - ``time_buffer`` is NULL
1428 * - ``RTEMS_INVALID_TIME_OF_DAY``
1429   - invalid time buffer
1430 * - ``RTEMS_NOT_DEFINED``
1431   - system date and time is not set
1432
1433**DESCRIPTION:**
1434
1435This directive blocks a task until the date and time specified in time_buffer.
1436At the requested date and time, the calling task will be unblocked and made
1437ready to execute.
1438
1439**NOTES:**
1440
1441The ticks portion of time_buffer structure is ignored.  The timing granularity
1442of this directive is a second.
1443
1444A clock tick is required to support the functionality of this directive.
1445
1446.. _rtems_iterate_over_all_threads:
1447
1448ITERATE_OVER_ALL_THREADS - Iterate Over Tasks
1449---------------------------------------------
1450.. index:: iterate over all threads
1451
1452**CALLING SEQUENCE:**
1453
1454.. index:: rtems_iterate_over_all_threads
1455
1456.. code-block:: c
1457
1458    typedef void (*rtems_per_thread_routine)(Thread_Control *the_thread);
1459    void rtems_iterate_over_all_threads(
1460        rtems_per_thread_routine routine
1461    );
1462
1463**DIRECTIVE STATUS CODES:**
1464
1465NONE
1466
1467**DESCRIPTION:**
1468
1469This directive iterates over all of the existant threads in the system and
1470invokes ``routine`` on each of them.  The user should be careful in accessing
1471the contents of ``the_thread``.
1472
1473This routine is intended for use in diagnostic utilities and is not intented
1474for routine use in an operational system.
1475
1476**NOTES:**
1477
1478There is NO protection while this routine is called.  Thus it is possible that
1479``the_thread`` could be deleted while this is operating.  By not having
1480protection, the user is free to invoke support routines from the C Library
1481which require semaphores for data structures.
1482
1483.. _rtems_task_variable_add:
1484
1485TASK_VARIABLE_ADD - Associate per task variable
1486-----------------------------------------------
1487.. index:: per-task variable
1488.. index:: task private variable
1489.. index:: task private data
1490
1491.. warning::
1492
1493  This directive is deprecated and task variables will be removed.
1494
1495**CALLING SEQUENCE:**
1496
1497.. index:: rtems_task_variable_add
1498
1499.. code-block:: c
1500
1501    rtems_status_code rtems_task_variable_add(
1502        rtems_id  tid,
1503        void    **task_variable,
1504        void    (*dtor)(void *)
1505    );
1506
1507**DIRECTIVE STATUS CODES:**
1508
1509.. list-table::
1510 :class: rtems-table
1511
1512 * - ``RTEMS_SUCCESSFUL``
1513   - per task variable added successfully
1514 * - ``RTEMS_INVALID_ADDRESS``
1515   - ``task_variable`` is NULL
1516 * - ``RTEMS_INVALID_ID``
1517   - invalid task id
1518 * - ``RTEMS_NO_MEMORY``
1519   - invalid task id
1520 * - ``RTEMS_ILLEGAL_ON_REMOTE_OBJECT``
1521   - not supported on remote tasks
1522
1523**DESCRIPTION:**
1524
1525This directive adds the memory location specified by the ptr argument to the
1526context of the given task.  The variable will then be private to the task.  The
1527task can access and modify the variable, but the modifications will not appear
1528to other tasks, and other tasks' modifications to that variable will not affect
1529the value seen by the task.  This is accomplished by saving and restoring the
1530variable's value each time a task switch occurs to or from the calling task.
1531If the dtor argument is non-NULL it specifies the address of a 'destructor'
1532function which will be called when the task is deleted.  The argument passed to
1533the destructor function is the task's value of the variable.
1534
1535**NOTES:**
1536
1537Task variables increase the context switch time to and from the tasks that own
1538them so it is desirable to minimize the number of task variables.  One
1539efficient method is to have a single task variable that is a pointer to a
1540dynamically allocated structure containing the task's private 'global' data.
1541In this case the destructor function could be 'free'.
1542
1543Per-task variables are disabled in SMP configurations and this service is not
1544available.
1545
1546.. _rtems_task_variable_get:
1547
1548TASK_VARIABLE_GET - Obtain value of a per task variable
1549-------------------------------------------------------
1550.. index:: get per-task variable
1551.. index:: obtain per-task variable
1552
1553.. warning::
1554
1555  This directive is deprecated and task variables will be removed.
1556
1557**CALLING SEQUENCE:**
1558
1559.. index:: rtems_task_variable_get
1560
1561.. code-block:: c
1562
1563    rtems_status_code rtems_task_variable_get(
1564        rtems_id  tid,
1565        void    **task_variable,
1566        void    **task_variable_value
1567    );
1568
1569**DIRECTIVE STATUS CODES:**
1570
1571.. list-table::
1572 :class: rtems-table
1573
1574 * - ``RTEMS_SUCCESSFUL``
1575   - per task variable obtained successfully
1576 * - ``RTEMS_INVALID_ADDRESS``
1577   - ``task_variable`` is NULL
1578 * - ``RTEMS_INVALID_ADDRESS``
1579   - ``task_variable_value`` is NULL
1580 * - ``RTEMS_INVALID_ADDRESS``
1581   - ``task_variable`` is not found
1582 * - ``RTEMS_NO_MEMORY``
1583   - invalid task id
1584 * - ``RTEMS_ILLEGAL_ON_REMOTE_OBJECT``
1585   - not supported on remote tasks
1586
1587**DESCRIPTION:**
1588
1589This directive looks up the private value of a task variable for a specified
1590task and stores that value in the location pointed to by the result argument.
1591The specified task is usually not the calling task, which can get its private
1592value by directly accessing the variable.
1593
1594**NOTES:**
1595
1596If you change memory which ``task_variable_value`` points to, remember to
1597declare that memory as volatile, so that the compiler will optimize it
1598correctly.  In this case both the pointer ``task_variable_value`` and data
1599referenced by ``task_variable_value`` should be considered volatile.
1600
1601Per-task variables are disabled in SMP configurations and this service is not
1602available.
1603
1604.. _rtems_task_variable_delete:
1605
1606TASK_VARIABLE_DELETE - Remove per task variable
1607-----------------------------------------------
1608.. index:: per-task variable
1609.. index:: task private variable
1610.. index:: task private data
1611
1612.. warning::
1613
1614  This directive is deprecated and task variables will be removed.
1615
1616**CALLING SEQUENCE:**
1617
1618.. index:: rtems_task_variable_delete
1619
1620.. code-block:: c
1621
1622    rtems_status_code rtems_task_variable_delete(
1623        rtems_id  id,
1624        void    **task_variable
1625    );
1626
1627**DIRECTIVE STATUS CODES:**
1628
1629.. list-table::
1630 :class: rtems-table
1631
1632 * - ``RTEMS_SUCCESSFUL``
1633   - per task variable deleted successfully
1634 * - ``RTEMS_INVALID_ID``
1635   - invalid task id
1636 * - ``RTEMS_NO_MEMORY``
1637   - invalid task id
1638 * - ``RTEMS_INVALID_ADDRESS``
1639   - ``task_variable`` is NULL
1640 * - ``RTEMS_ILLEGAL_ON_REMOTE_OBJECT``
1641   - not supported on remote tasks
1642
1643**DESCRIPTION:**
1644
1645This directive removes the given location from a task's context.
1646
1647**NOTES:**
1648
1649Per-task variables are disabled in SMP configurations and this service
1650is not available.
Note: See TracBrowser for help on using the repository browser.