source: rtems-docs/c-user/task_manager.rst @ 40a1e80

5
Last change on this file since 40a1e80 was 40a1e80, checked in by Sebastian Huber <sebastian.huber@…>, on 01/31/17 at 09:10:13

c-user: Task names

Update #2858.

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