OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [doc/] [user/] [task.t] - Blame information for rev 1780

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.