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