When you create a task, it is provided with its own run-time stack,
used for storing local variables as well as for further nesting of
function calls. Each stack must be large enough to handle normal
subroutine calls and one task preemption context.
A task preemption context is the context that gets saved when one task
preempts another as a result of an interrupt thread readying
a higher-priority task.
All tasks executing within a single program share a common set of
global variables, accessed according to the standard rules of scope
defined for C functions.
Each task is in one of five modes of execution at any point in time:
running, ready, blocked, terminated, or inactive. By design, there is
always one
(and only one) task currently running, even if it is only the idle task
managed internally by Task. The current task can be suspended from
execution by calling certain Task functions, as well as functions
provided by other modules like the Semaphore or Event Modules.
The current task
can also terminate its own execution. In either case, the processor
is switched to the highest priority task that is ready to run.
You can assign numeric priorities to tasks. Tasks are
readied for execution in strict priority order; tasks of the same
priority are scheduled on a first-come, first-served basis.
The priority of the currently running task is never lower
than the priority of any ready task. Conversely, the running task
is preempted and re-scheduled for execution whenever there exists
some ready task of higher priority.
Stack size parameters for both static and dynamic tasks are rounded
up to the nearest integer multiple of a target specific alignment
requirement.
In the case of Task's which are created with a user-provided stack,
both the base address and the stackSize are aligned. The base address
is increased to the nearest aligned address. The stack size is decreased
accordingly and then rounded down to the nearest integer multiple of the
target-specific required alignment.
Sets of hook functions can be specified for the Task module. Each
set constains these hook functions:
Hook functions can only be configured statically.
The create and delete functions are called whenever a Task is created
or deleted. They are called with interrupts enabled (unless called
at boot time or from main()).
If a switch function is specified, it is invoked just before the new task
is switched to. The switch function is called with interrupts enabled.
This function can be used to save/restore additional task context (for
example, external hardware registers), to check for task stack overflow,
to monitor the time used by each task, etc.
If a ready function is specified, it is invoked whenever a task is made
ready to run. The ready function is called with interrupts enabled
(unless called at boot time or from main()).
If an exit function is specified, it is invoked when a task exits (via
call to Task_exit() or when a task returns from its' main function).
The Exit Function is called with interrupts enabled.
enum Task.Mode |
|
Task execution modes
XDCscript usage |
meta-domain |
values of type Task.Mode
const Task.Mode_RUNNING;
// Task is currently executing
const Task.Mode_READY;
// Task is scheduled for execution
const Task.Mode_BLOCKED;
// Task is suspended from execution
const Task.Mode_TERMINATED;
// Task is terminated from execution
const Task.Mode_INACTIVE;
// Task is on inactive task list
typedef enum Task_Mode {
Task_Mode_RUNNING,
// Task is currently executing
Task_Mode_READY,
// Task is scheduled for execution
Task_Mode_BLOCKED,
// Task is suspended from execution
Task_Mode_TERMINATED,
// Task is terminated from execution
Task_Mode_INACTIVE
// Task is on inactive task list
} Task_Mode;
DETAILS
These enumerations are the range of modes or states that
a task can be in. A task's current mode can be gotten using
stat.
typedef Task.FuncPtr |
|
Task function type definition
typedef Void (*Task_FuncPtr)(UArg,UArg);
metaonly struct Task.BasicView |
|
XDCscript usage |
meta-domain |
var obj = new Task.BasicView;
obj.label = String ...
obj.priority = Int ...
obj.mode = String ...
obj.fxn = String[] ...
obj.arg0 = UArg ...
obj.arg1 = UArg ...
obj.stackSize = SizeT ...
obj.stackBase = Ptr ...
metaonly struct Task.DetailedView |
|
XDCscript usage |
meta-domain |
var obj = new Task.DetailedView;
obj.label = String ...
obj.priority = Int ...
obj.mode = String ...
obj.fxn = String[] ...
obj.arg0 = UArg ...
obj.arg1 = UArg ...
obj.stackPeak = SizeT ...
obj.stackSize = SizeT ...
obj.stackBase = Ptr ...
obj.blockedOn = String ...
struct Task.HookSet |
|
Task hook set type definition
XDCscript usage |
meta-domain |
var obj = new Task.HookSet;
obj.registerFxn = Void(*)(Int) ...
typedef struct Task_HookSet {
Void (*registerFxn)(Int);
} Task_HookSet;
metaonly struct Task.ModuleView |
|
XDCscript usage |
meta-domain |
var obj = new Task.ModuleView;
obj.schedulerState = String ...
obj.readyQMask = String ...
obj.workPending = Bool ...
obj.numVitalTasks = UInt ...
obj.currentTask = Ptr ...
obj.hwiStackPeak = SizeT ...
obj.hwiStackSize = SizeT ...
obj.hwiStackBase = Ptr ...
struct Task.Stat |
|
Task Status Buffer
XDCscript usage |
meta-domain |
var obj = new Task.Stat;
obj.priority = Int ...
// Task priority
obj.stack = Ptr ...
// Task stack
obj.stackSize = SizeT ...
// Task stack size
// Heap used to alloc stack
obj.env = Ptr ...
// Global environment struct
// Task's current mode
obj.sp = Ptr ...
// Task's current stack pointer
obj.used = SizeT ...
// max # of words used on stack
typedef struct Task_Stat {
Int priority;
// Task priority
Ptr stack;
// Task stack
SizeT stackSize;
// Task stack size
// Heap used to alloc stack
Ptr env;
// Global environment struct
// Task's current mode
Ptr sp;
// Task's current stack pointer
SizeT used;
// max # of words used on stack
} Task_Stat;
DETAILS
Passed to and filled in by
stat;
config Task.A_allBlocked // module-wide |
|
Assert if all tasks are blocked
XDCscript usage |
meta-domain |
msg: "A_allBlocked: All tasks blocked."
};
DETAILS
This can only happen if the
idle task blocks (via I/O call, call to Semaphore_pend(), etc.).
This should never happen since the idle task should never block.
config Task.A_badPriority // module-wide |
|
Asserted in Task_create
XDCscript usage |
meta-domain |
msg: "A_badPriority: An invalid task priority was used."
};
config Task.A_badTaskState // module-wide |
|
Asserted in Task_delete
XDCscript usage |
meta-domain |
msg: "A_badTaskState: Can't delete a task in BLOCKED or RUNNING state."
};
config Task.A_badThreadType // module-wide |
|
Asserted in Task_create and Task_delete
XDCscript usage |
meta-domain |
msg: "A_badThreadType: Cannot create/delete a task from Hwi or Swi thread."
};
config Task.A_badTimeout // module-wide |
|
Asserted in Task_sleep
XDCscript usage |
meta-domain |
msg: "A_badTimeout: Can't sleep FOREVER."
};
config Task.A_taskDisabled // module-wide |
|
Asserted in Task_create
XDCscript usage |
meta-domain |
msg: "A_taskDisabled: Cannot create a task when tasking is disabled."
};
config Task.E_stackOverflow // module-wide |
|
Error raised when a stack overflow (or corruption) is detected
XDCscript usage |
meta-domain |
msg: "E_stackOverflow: Task '%s' stack overflow."
};
extern const Error_Id Task_E_stackOverflow;
DETAILS
This error is raised by kernel's stack checking function. This
function checks the stacks before every task switch to make sure
that reserved word at top of stack has not been modified.
The stack checking logic is enabled by the
initStackFlag and
checkStackFlag configuration parameters. If both of these
flags are set to true, the kernel will validate the stacks.
config Task.LD_block // module-wide |
|
Logged when a task is blocked (ie Semaphore_pend())
XDCscript usage |
meta-domain |
msg: "LD_block: tsk: 0x%x, func: 0x%x"
};
config Task.LD_exit // module-wide |
|
Logged when Task functions fall thru the bottom
or when Task_exit() is explicitly called
XDCscript usage |
meta-domain |
msg: "LD_exit: tsk: 0x%x, func: 0x%x"
};
config Task.LD_ready // module-wide |
|
Logged when a task is made ready to run (ie Semaphore_post())
XDCscript usage |
meta-domain |
msg: "LD_ready: tsk: 0x%x, func: 0x%x, pri: %d"
};
config Task.LM_setPri // module-wide |
|
Logged on calls to Task_setPri
XDCscript usage |
meta-domain |
msg: "LM_setPri: tsk: 0x%x, func: 0x%x, oldPri: %d, newPri %d"
};
config Task.LM_sleep // module-wide |
|
Logged on calls to Task_sleep
XDCscript usage |
meta-domain |
msg: "LM_sleep: tsk: 0x%x, func: 0x%x, timeout: %d"
};
config Task.LM_switch // module-wide |
|
Logged on every task switch
XDCscript usage |
meta-domain |
msg: "LM_switch: oldtsk: 0x%x, oldfunc: 0x%x, newtsk: 0x%x, newfunc: 0x%x"
};
config Task.LM_yield // module-wide |
|
Logged on calls to Task_yield
XDCscript usage |
meta-domain |
msg: "LM_yield: tsk: 0x%x, func: 0x%x, currThread: %d"
};
config Task.defaultStackHeap // module-wide |
|
Default Mem heap used for all dynamically created task stacks
XDCscript usage |
meta-domain |
DETAILS
Default is null.
config Task.defaultStackSize // module-wide |
|
Default stack size (in MAUs) used for all tasks
XDCscript usage |
meta-domain |
Task.defaultStackSize = SizeT undefined;
extern const SizeT Task_defaultStackSize;
DETAILS
Default is obtained from the target-specific Task_Support module.
config Task.hooks // module-wide |
|
const array that holds the HookSet objects
XDCscript usage |
meta-domain |
config Task.initStackFlag // module-wide |
|
Initialize stack with known value for stack checking at runtime
(see checkStackFlag)
XDCscript usage |
meta-domain |
Task.initStackFlag = Bool true;
extern const Bool Task_initStackFlag;
DETAILS
This is also useful for inspection of stack in debugger or core
dump utilities.
Default is true.
config Task.numPriorities // module-wide |
|
Number of Task priorities supported. Default is 16
XDCscript usage |
meta-domain |
Task.numPriorities = UInt 16;
extern const UInt Task_numPriorities;
DETAILS
The maximum number of priorities supported is
target specific and depends on the number of
bits in a UInt data type. For 6x and Arm devices
the maximum number of priorities is therefore 32.
For 28x and 55x devices, the maximum number of
priorities is 16.
metaonly config Task.checkStackFlag // module-wide |
|
Check 'from' and 'to' task stacks before task context switch
XDCscript usage |
meta-domain |
Task.checkStackFlag = Bool true;
DETAILS
The check consists of testing the top of stack value against
its initial value (see
initStackFlag). If it is no
longer at this value, the assumption is that the task has
overrun its stack. If the test fails, then the
E_stackOverflow error is raised.
Runtime stack checking is only performed if
initStackFlag is
also true.
Default is true.
metaonly config Task.common$ // module-wide |
|
Common module configuration parameters
XDCscript usage |
meta-domain |
DETAILS
All modules have this configuration parameter. Its name
contains the '$' character to ensure it does not conflict with
configuration parameters declared by the module. This allows
new configuration parameters to be added in the future without
any chance of breaking existing modules.
metaonly config Task.defaultStackSection // module-wide |
|
Default memory section used for all statically created task stacks
XDCscript usage |
meta-domain |
Task.defaultStackSection = String ".taskStackSection";
DETAILS
The default stack section name is ".taskStackSection" which gets placed
into the platform's stackMemory (ie Program.platform.stackMemory).
To place all task stacks into a different memory segment,
add the following to your config script:
Program.sectMap[Task.defaultStackSection] = new Program.SectionSpec();
Program.sectMap[Task.defaultStackSection].loadSegment = "yourMemorySegment";
To place all task stacks into a different section AND memory segment,
add the following to your config script:
Task.defaultStackSection = ".yourSectionName";
Program.sectMap[Task.defaultStackSection] = new Program.SectionSpec();
Program.sectMap[Task.defaultStackSection].loadSegment = "yourMemorySegment";
Where "yourSectionName" can be just about anything, and "yourMemorySegment"
must be a memory segment defined within the
Program.platform
the application is being built for.
metaonly config Task.idleTaskStackSection // module-wide |
|
Idle task stack section
XDCscript usage |
meta-domain |
Task.idleTaskStackSection = String undefined;
DETAILS
Default is inherited from module config defaultStackSection;
metaonly config Task.idleTaskStackSize // module-wide |
|
Idle task stack size in MAUs
XDCscript usage |
meta-domain |
Task.idleTaskStackSize = SizeT undefined;
DETAILS
Default is inherited from module config defaultStackSize.
metaonly config Task.idleTaskVitalTaskFlag // module-wide |
|
Idle task's vitalTaskFlag.
(see vitalTaskFlag)
XDCscript usage |
meta-domain |
Task.idleTaskVitalTaskFlag = Bool true;
DETAILS
Default is true.
Task.disable( ) // module-wide |
|
Disable the task scheduler
RETURNS
DETAILS
disable and
restore control Task scheduling.
disable disables all other Tasks from running until
restore is called. Hardware and Software interrupts
can still run.
disable and
restore allow you to ensure that
statements
that must be performed together during critical processing are not
preempted by other Tasks.
The value of the key returned is opaque to applications and is meant
to be passed to Task_restore().
In the following example, the critical section is
not preempted by any Tasks.
key = Task_disable();
`critical section`
Task_restore(key);
You can also use
disable and
restore to
create several Tasks and allow them to be invoked in
priority order.
disable calls can be nested.
CONSTRAINTS
Do not call any function that can cause the current task to block
within a
disable/
restore block. For example,
Semaphore_pend
(if timeout is non-zero),
sleep,
yield, and Memory_alloc can all
cause blocking.
Task.exit( ) // module-wide |
|
Terminate execution of the current task
DETAILS
Task_exit terminates execution of the current task, changing its mode
from
Mode_RUNNING to
Mode_TERMINATED. If all tasks
have been terminated, or if all remaining tasks have their
vitalTaskFlag attribute set to FALSE, then DSP/BIOS terminates the
program as a whole by calling the function System_exit with a status
code of 0.
Task_exit is automatically called whenever a task returns from its
toplevel function.
Exit Hooks (see exitFxn in
HookSet) can be used to provide
functions that run whenever a task is terminated. The exitFxn Hooks
are called before the task has been blocked and marked
Mode_TERMINATED.
Any DSP/BIOS function can be called from an Exit Hook function.
Calling
self within an Exit function returns the task
being exited. Your Exit function declaration should be similar to
the following:
A task switch occurs when calling Task_exit unless the program as a
whole is terminated
CONSTRAINTS
Task_exit cannot be called from a Swi or Hwi.
Task_exit cannot be called from the program's main() function.
Task.getIdleTask( ) // module-wide |
|
returns a handle to idle task object
Task.restore( ) // module-wide |
|
Restore Task scheduling state
Void Task_restore( UInt key );
ARGUMENTS
key
key to restore previous Task scheduler state
DETAILS
disable and
restore control Task scheduling
disable disables all other Tasks from running until
restore is called. Hardware and Software interrupts
can still run.
disable and
restore allow you to ensure that statements
that must be performed together during critical processing are not
preempted.
In the following example, the critical section is not preempted
by any Tasks.
key = Task_disable();
`critical section`
Task_restore(key);
You can also use
disable and
restore to create
several Tasks and allow them to be performed in priority order.
disable calls can be nested.
restore returns with interrupts enabled if the key unlocks
the scheduler
CONSTRAINTS
Do not call any function that can cause the current task to block
within a
disable/
restore block. For example,
Semaphore_pend()
(if timeout is non-zero),
sleep,
yield, and Memory_alloc can all
cause blocking.
restore internally calls Hwi_enable() if the key passed
to it results in the unlocking of the Task scheduler (ie if this
is root Task_disable/Task_restore pair).
Task.self( ) // module-wide |
|
Returns a handle to the currently executing Task object
RETURNS
address of currently executing task object
DETAILS
Task_self returns the object handle for the currently executing task.
This function is useful when inspecting the object or when the current
task changes its own priority through
setPri.
No task switch occurs when calling Task_self.
Task_self will return NULL until Tasking is initiated at the end of
BIOS_start().
Task.sleep( ) // module-wide |
|
Delay execution of the current task
Void Task_sleep( UInt nticks );
ARGUMENTS
nticks
number of system clock ticks to sleep
DETAILS
Task_sleep changes the current task's mode from
Mode_RUNNING
to
Mode_BLOCKED, and delays its execution for nticks
increments of the system clock. The actual time delayed can be up to
1 system clock tick less than nticks due to granularity in system
timekeeping.
After the specified period of time has elapsed, the task reverts to
the
Mode_READY mode and is scheduled for execution.
A task switch always occurs when calling Task_sleep if nticks > 0.
CONSTRAINTS
Task_sleep cannot be called from a Swi or Hwi, or within a
disable /
restore block.
Task_sleep cannot be called from the program's main() function.
Task_sleep should not be called from within an Idle function. Doing
so prevents analysis tools from gathering run-time information.
nticks cannot be
BIOS_WAIT_FOREVER.
Task.yield( ) // module-wide |
|
Yield processor to equal priority task
DETAILS
Task_yield yields the processor to another task of equal priority.
A task switch occurs when you call Task_yield if there is an equal
priority task ready to run.
Tasks of higher priority preempt the currently running task without
the need for a call to Task_yield. If only lower-priority tasks are
ready to run when you call Task_yield, the current task continues to
run. Control does not pass to a lower-priority task.
CONSTRAINTS
When called within an Hwi, the code sequence calling Task_yield
must be invoked by the Hwi dispatcher.
Task_yield cannot be called from the program's main() function.
metaonly Task.addHookSet( ) // module-wide |
|
addHookSet is used in a config file to add a hook set (defined
by struct HookSet)
XDCscript usage |
meta-domain |
ARGUMENTS
hook
structure of type HookSet
DETAILS
HookSet structure elements may be omitted, in which case those
elements will not exist.
metaonly Task.getNickName( ) // module-wide |
|
XDCscript usage |
meta-domain |
Task.getNickName( Any tskView ) returns String
module-wide built-ins |
|
// Get this module's unique id
Bool Task_Module_startupDone( );
// Test if this module has completed startup
// The heap from which this module allocates memory
Bool Task_Module_hasMask( );
// Test whether this module has a diagnostics mask
Bits16 Task_Module_getMask( );
// Returns the diagnostics mask for this module
Void Task_Module_setMask( Bits16 mask );
// Set the diagnostics mask for this module
per-instance object types |
|
typedef struct Task_Object Task_Object;
// Opaque internal representation of an instance object
// Client reference to an instance object
typedef struct Task_Struct Task_Struct;
// Opaque client structure large enough to hold an instance object
// Convert this instance structure pointer into an instance handle
// Convert this instance handle into an instance structure pointer
per-instance config parameters |
|
XDCscript usage |
meta-domain |
var params = new Task.Params;
// Instance config-params object
params.arg0 = UArg 0;
// Task function argument. Default is 0
params.arg1 = UArg 0;
// Task function argument. Default is 0
params.env = Ptr null;
// Environment data struct
params.priority = Int 1;
// Task priority (0 to numPriorities-1 or -1).
Default is 1
params.stack = Ptr null;
// Task stack pointer. Default = null.
null indicates that the stack is to be allocated by create()
// Mem heap used for dynamically created task stack.
The default value of NULL means that the module config
{@link #defaultStackHeap} is used
params.stackSection = String undefined;
// Mem section used for statically created task stacks.
Default is inherited from module config defaultStackSection
params.stackSize = SizeT 0;
// Task stack size in MAUs.
The default value of 0 means that the module config
{@link #defaultStackSize} is used
params.vitalTaskFlag = Bool true;
// Exit system immediately when the last task with this
flag set to TRUE has terminated. Default is true
typedef struct Task_Params {
// Instance config-params structure
// Common per-instance configs
UArg arg0;
// Task function argument. Default is 0
UArg arg1;
// Task function argument. Default is 0
Ptr env;
// Environment data struct
Int priority;
// Task priority (0 to numPriorities-1 or -1).
Default is 1
Ptr stack;
// Task stack pointer. Default = null.
null indicates that the stack is to be allocated by create()
// Mem heap used for dynamically created task stack.
The default value of NULL means that the module config
{@link #defaultStackHeap} is used
SizeT stackSize;
// Task stack size in MAUs.
The default value of 0 means that the module config
{@link #defaultStackSize} is used
Bool vitalTaskFlag;
// Exit system immediately when the last task with this
flag set to TRUE has terminated. Default is true
} Task_Params;
// Initialize this config-params structure with supplier-specified defaults before instance creation
config Task.arg0 // per-instance |
|
Task function argument. Default is 0
XDCscript usage |
meta-domain |
var params = new Task.Params;
...
params.arg0 = UArg 0;
config Task.arg1 // per-instance |
|
Task function argument. Default is 0
XDCscript usage |
meta-domain |
var params = new Task.Params;
...
params.arg1 = UArg 0;
config Task.env // per-instance |
|
Environment data struct
XDCscript usage |
meta-domain |
var params = new Task.Params;
...
params.env = Ptr null;
config Task.priority // per-instance |
|
Task priority (0 to numPriorities-1 or -1).
Default is 1
XDCscript usage |
meta-domain |
var params = new Task.Params;
...
params.priority = Int 1;
config Task.stack // per-instance |
|
Task stack pointer. Default = null.
null indicates that the stack is to be allocated by create()
XDCscript usage |
meta-domain |
var params = new Task.Params;
...
params.stack = Ptr null;
DETAILS
Example: To statically initialize "tsk0"'s stack to a literal
address, use the following syntax:
Program.global.tsk0.stack = $addr(literal);
config Task.stackHeap // per-instance |
|
Mem heap used for dynamically created task stack.
The default value of NULL means that the module config
defaultStackHeap is used
XDCscript usage |
meta-domain |
var params = new Task.Params;
...
config Task.stackSize // per-instance |
|
Task stack size in MAUs.
The default value of 0 means that the module config
defaultStackSize is used
XDCscript usage |
meta-domain |
var params = new Task.Params;
...
params.stackSize = SizeT 0;
config Task.vitalTaskFlag // per-instance |
|
Exit system immediately when the last task with this
flag set to TRUE has terminated. Default is true
XDCscript usage |
meta-domain |
var params = new Task.Params;
...
params.vitalTaskFlag = Bool true;
metaonly config Task.stackSection // per-instance |
|
Mem section used for statically created task stacks.
Default is inherited from module config defaultStackSection
XDCscript usage |
meta-domain |
var params = new Task.Params;
...
params.stackSection = String undefined;
per-instance creation |
|
XDCscript usage |
meta-domain |
// Allocate instance config-params
params.config = ...
// Assign individual configs
var inst = Task.create( Void(*)(UArg,UArg) fxn, params );
// Create an instance-object
// Allocate and initialize a new instance object and return its handle
// Initialize a new instance object inside the provided structure
ARGUMENTS
fxn
Task Function
params
per-instance config params, or NULL to select default values (target-domain only)
eb
active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
Task_create creates a new task object. If successful, Task_create
returns the handle of the new task object. If unsuccessful,
Task_create returns NULL unless it aborts.
The fxn parameter uses the
FuncPtr type to pass a pointer to
the function the Task object should run. For example, if myFxn is a
function in your program, you can create a Task object to call that
function as follows:
task = Task_create((Task_FuncPtr)myFxn, NULL, NULL);
You can specify application-wide Create functions in your config
file that run whenever a task is created. This includes tasks that
are created statically and those created dynamically using
Task_create.
For Task objects created statically, Create functions are called
during the Task module initialization phase of the program startup
process prior to main().
For Task objects created dynamically, Create functions
are called after the task handle has been initialized but before the
task has been placed on its ready queue.
Any DSP/BIOS function can be called from Create functions.
DSP/BIOS passes the task handle of the task being created to each of
the Create functions.
All Create function declarations should be similar to this:
Void myCreateFxn(Task_Handle task);
The newly created task is placed in
Mode_READY mode, and is
scheduled to begin concurrent execution of the following function
call:
As a result of being made ready to run, the task runs any
application-wide Ready functions that have been specified.
Task_exit is automatically called if and when the task returns
from fxn.
If params is NULL, the new task is assigned a default
set of configuration parameters as described below.
CONSTRAINTS
The fxn parameter and the name attribute cannot be NULL.
The priority attribute must be less than or equal to
(
numPriorities - 1) and greater than or equal to one (1)
(priority 0 is owned by the Idle task).
The priority can be less than zero (0) for tasks that should not
execute.
The stackHeap attribute must identify a valid memory Heap.
per-instance deletion |
|
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
// Finalize the instance object inside the provided structure
Task.getEnv( ) // per-instance |
|
Get task environment pointer
ARGUMENTS
handle
handle of a previously-created Task instance object
RETURNS
task environment pointer
DETAILS
Task_getEnv returns the environment pointer of the specified task. The
environment pointer references an arbitrary application-defined data
structure.
If your program uses multiple hook sets,
getHookContext
allows you to get environment pointers you have set for a particular
hook set and Task object combination.
Task.getHookContext( ) // per-instance |
|
Get hook set's context for a task
ARGUMENTS
handle
handle of a previously-created Task instance object
id
hook set ID
RETURNS
hook set context for task
Task.getMode( ) // per-instance |
|
Retrieve the Mode of a task
ARGUMENTS
handle
handle of a previously-created Task instance object
Task.getPri( ) // per-instance |
|
Get task priority
ARGUMENTS
handle
handle of a previously-created Task instance object
RETURNS
task priority
DETAILS
Task_getPri returns the priority of the referenced task.
Task.setEnv( ) // per-instance |
|
Set task environment
ARGUMENTS
handle
handle of a previously-created Task instance object
env
task environment pointer
DETAILS
Task_setEnv sets the task environment pointer to env. The
environment pointer references an arbitrary application-defined
data structure.
If your program uses multiple hook sets,
setHookContext
allows you to set environment pointers for any
hook set and Task object combination.
Task.setHookContext( ) // per-instance |
|
Set hook instance's context for a task
Void Task_setHookContext(
Task_Handle handle,
Int id,
Ptr hookContext );
ARGUMENTS
handle
handle of a previously-created Task instance object
id
hook set ID
hookContext
value to write to context
Task.setPri( ) // per-instance |
|
Set a task's priority
ARGUMENTS
handle
handle of a previously-created Task instance object
newpri
task's new priority
RETURNS
task's old priority
DETAILS
Task_setpri sets the execution priority of task to newpri, and returns
that task's old priority value. Raising or lowering a task's priority
does not necessarily force preemption and re-scheduling of the caller:
tasks in the
Mode_BLOCKED mode remain suspended despite a
change in priority; and tasks in the
Mode_READY mode gain
control only if their new priority is greater than that of the
currently executing task.
The maximum value of newpri is (
numPriorities - 1).
The minimum value of newpri is one (1) (The Idle task owns priority 0).
If newpri is less than 0, the task is barred from further execution
until its priority is raised at a later time by another task; if newpri
equals (
numPriorities - 1), execution of the task effectively
locks out all other program activity, except for the handling of
interrupts.
The current task can change its own priority (and possibly preempt its
execution) by passing the output of
self as the value of the
task parameter.
A context switch occurs when calling Task_setpri if a currently
running task priority is set lower than the priority of another
currently ready task, or if another ready task is made to have a
higher priority than the currently running task.
Task_setpri can be used for mutual exclusion.
If a task's new priority is different than its previous priority,
then it's relative placement in it's new ready task priority
queue can be different than the one it was removed from. This can
effect the relative order in which it becomes the running task.
The effected task is placed at the head of its new priority queue
if it is the currently running task. Otherwise it is placed at
at the end of its new task priority queue.
CONSTRAINTS
newpri must be less than or equal to (
numPriorities - 1).
The task cannot be in the
Mode_TERMINATED mode.
The new priority should not be zero (0). This priority level is
reserved for the Idle task.
Task.stat( ) // per-instance |
|
Retrieve the status of a task
ARGUMENTS
handle
handle of a previously-created Task instance object
statbuf
pointer to task status structure
DETAILS
Task_stat retrieves attribute values and status information about a
task.
Status information is returned through statbuf, which references a
structure of type
Stat.
When a task is preempted by a software or hardware interrupt, the task
execution mode returned for that task by Task_stat is still
Mode_RUNNING because the task runs when the preemption ends.
The current task can inquire about itself by passing the output of
self as the first argument to Task_stat. However, the task
stack pointer (sp) in the
Stat structure is the value from
the previous context switch.
Task_stat has a non-deterministic execution time. As such, it is not
recommended to call this API from Swis or Hwis.
CONSTRAINTS
statbuf cannot be NULL;
per-instance built-ins |
|
Int Task_Object_count( );
// The number of statically-created instance objects
// The handle of the i-th statically-created instance object (array == NULL)
// The handle of the first dynamically-created instance object, or NULL
// The handle of the next dynamically-created instance object, or NULL
// The heap used to allocate dynamically-created instance objects
// The label associated with this instance object
// The name of this instance object