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