source: rtems/doc/user/task.t @ 2a6a029f

4.104.114.84.95
Last change on this file since 2a6a029f was 2a6a029f, checked in by Joel Sherrill <joel.sherrill@…>, on 07/01/99 at 23:06:29

Added error status for bad return pointer argument on rtems_task_set_priority.

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