source: rtems/doc/user/task.t @ 75e22db

4.104.114.84.95
Last change on this file since 75e22db was 75e22db, checked in by Joel Sherrill <joel.sherrill@…>, on 03/27/98 at 16:47:53

Completed sweep adding directive and constant prefixes.

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