Operating System Configuration

The following configuration constants relate to the µC/TELNETs OS port. For many OSs, the µC/TELNETs task priority and stack size will need to be explicitly configured for the particular OS (consult the specific OS’s documentation for more information).

The priority of µC/TELNETs task is dependent on the requirements of the application.

For μC/OS-II and μC/OS-III, the following macros must be configured within telnet-s_cfg.h or any configuration file as long as it is included by telenet-s_cfg.h.

Constant
Description
Possible Values
TELNETs_OS_CFG_SERVER_TASK_PRIO Configure the µC/TELNETs server task priority.Any integer value within the OS priorities range.
TELNETs_OS_CFG_SESSION_TASK_PRIOConfigure the µC/TELNETs session task priority.Any integer value within the OS priorities range.
TELNETs_OS_CFG_SERVER_TASK_STK_SIZEConfigure the µC/TELNETs server task stack size.Any integer value.
TELNETs_OS_CFG_SESSION_TASK_STK_SIZEConfigure the µC/TELNETs sesssion task stack size.Any integer value.

Task Priorities

The values assigned depend upon the software architecture of your system, and on the importance of this module’s response time relative to other tasks. It is recommended, however, to give consecutive task priorities to the two µC/TELNETs tasks, and the server task should have higher priority than the session task.

Task Stack Size

In general, the size of µC/TELNETs 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 to invest in a task stack calculator tool compatible with your build toolchain.

On ARM processors, experience has shown that configuring the task stacks to 1024 OS_STK entries (4,096 bytes) is sufficient for most applications. Certainly, the stack sizes may be examined and reduced accordingly once the run-time behavior of the device has been analyzed and additional stack space deemed to be unnecessary.