Tasks
Thread Scheduling 4-39
4.4 Tasks
DSP/BIOS task objects are threads that are managed by the TSK module.
Tasks have higher priority than the idle loop and lower priority than hardware
and software interrupts.
The TSK module dynamically schedules and preempts tasks based on the
task’s priority level and the task’s current execution state. This ensures that
the processor is always given to the highest priority thread that is ready to run.
There are 15 priority levels available for tasks. The lowest priority level (0) is
reserved for running the idle loop.
The TSK module provides a set of functions that manipulate task objects.
They access TSK object through handles of type TSK_Handle.
The kernel maintains a copy of the processor registers for each task object.
Each task has its own run-time stack for storing local variables as well as for
further nesting of function calls.
Stack size can be specified separately for each TSK object. 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. If the task blocks, only those registers that a C function
must save are saved to the task stack. To find the correct stack size, you can
make the stack size large and then use Code Composer Studio software to
find the stack size actually used.
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.
4.4.1 Creating Tasks
You can create TSK objects either dynamically (with a call to TSK_create) or
statically (in the configuration). Tasks that you create dynamically can also be
deleted during program execution.