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