TSK Module
2-476
A single set of hook functions can be specified for the TSK module itself.
To create additional sets of hook functions, use the HOOK Module. When
you create the first HOOK object, any TSK module hook functions you
have specified are automatically placed in a HOOK object called
HOOK_KNL. To set any properties of this object other than the
Initialization function, use the TSK module properties. To set the
Initialization function property of the HOOK_KNL object, use the HOOK
object properties. If you configure only a single set of hook functions
using the TSK module, the HOOK module is not used.
The TSK_create topic describes the Create function. The TSK_delete
topic describes the Delete function. The TSK_exit topic describes the Exit
function.
If a Switch function is specified, it is invoked when a new task becomes
the TSK_RUNNING task. The Switch function gives the application
access to both the current and next task handles at task switch time. The
function should use these argument types:
Void mySwitchFxn(TSK_Handle currTask,
TSK_Handle nextTask);
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. Even if a higher-priority thread is running, the Ready
function runs. The Ready function is called with a handle to the task being
made ready to run as its argument. This example function prints the
name of both the task that is ready to run and the task that is currently
running:
Void myReadyFxn(TSK_Handle task)
{
String nextName, currName;
TSK_Handle currTask = TSK_self();
nextName = TSK_getname(task);
LOG_printf(&trace, “Task %s Ready”, nextName);
currName = TSK_getname(currTask);
LOG_printf(&trace, “Task %s Running”, currName);
}