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