TSK Module
Application Program Interface
2-475
Description
The TSK module makes available a set of functions that manipulate task
objects accessed through handles of type TSK_Handle. Tasks represent
independent threads of control that conceptually execute functions in
parallel within a single C program; in reality, concurrency is achieved by
switching the processor from one task to the next.
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.
The TSK_STACKSTAMP value is used to initialize the run-time stack.
When creating a task dynamically, you need to initialize the stack with
TSK_STACKSTAMP only if the stack is allocated manually and
TSK_checkstacks or TSK_stat is to be called. Each stack must be large
enough to handle normal subroutine calls as well as a single 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 four modes of execution at any point in time:
running, ready, blocked, or terminated. By design, there is always one
(and only one) task currently running, even if it is a dummy idle task
managed internally by TSK. The current task can be suspended from
execution by calling certain TSK functions, as well as functions provided
by other modules like the SEM Module and the SIO Module; the current
task can also terminate its own execution. In either case, the processor
is switched to the next task that is ready to run.
You can assign numeric priorities to tasks through TSK. Tasks are
readied for execution in strict priority order; tasks of the same priority are
scheduled on a first-come, first-served basis. As a rule, 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.
You can use Tconf to specify one or more sets of application-wide hook
functions that run whenever a task state changes in a particular way. For
the TSK module, these functions are the Create, Delete, Exit, Switch, and
Ready functions. The HOOK module adds an additional Initialization
function.
exitFlag
Bool
true
allocateTaskName
Bool
false
order
Int16
0
Name
Type
Default (Enum Options)