source: rtems/doc/user/task.t @ 169502e

4.104.114.84.95
Last change on this file since 169502e was 169502e, checked in by Joel Sherrill <joel.sherrill@…>, on 10/11/99 at 19:03:05

Turned on concept and function name indexing.

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