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