Task Configuration
This section defines the configuration structures related to μC/Clk but that are application-specific. All these configurations relate to the RTOS. For many OSs, the μC/Clk task priorities and stack sizes will need to be explicitly configured for the particular OS (consult the specific OS’s documentation for more information).
These configurations are defined in the Cfg/Template/clk_cfg.c
file.
Clk Task Configuration
µC/Clk use the following structure to configure its network tasks.
typedef struct clk_task_cfg { CPU_INT32U Prio; /* Task priority. */ CPU_INT32U StkSizeBytes; /* Size of the stack. */ void *StkPtr; /* Pointer to base of the stack. */ } CLK_TASK_CFG;
Task Priority
The value assigned depends upon the software architecture of your system, and on the importance of this module’s response time relative to other tasks.
Task Stack Size
In general, the size of µC/Clk task stacks is dependent on the CPU architecture and compiler used.
The only guaranteed method of determining the required task stack sizes is to calculate the maximum stack usage for each task. Obviously, the maximum stack usage for a task is the total stack usage along the task’s most-stack-greedy function path plus the (maximum) stack usage for interrupts. Note that the most-stack-greedy function path is not necessarily the longest or deepest function path.
The easiest and best method for calculating the maximum stack usage for any task/function should be performed statically by the compiler or by a static analysis tool since these can calculate function/task maximum stack usage based on the compiler’s actual code generation and optimization settings. So for optimal task stack configuration, we recommend you invest in a task stack calculator tool compatible with your build toolchain.
Task Stack Location and Allocation
If a specific memory location is desired for a task stack, the StkPtr
parameter can be set to point to this specific memory segment. Else, if StkPtr
is set to NULL, the task stack will be allocated on µC/LIB Heap.