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

4.115
Last change on this file since b8d3f6b was b8d3f6b, checked in by Chris Johns <chrisj@…>, on 01/24/16 at 10:37:53

C user guide clean up. Up to timer manager.

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