Embedded Design Handbook

ID 683689
Date 8/28/2023
Public
Document Table of Contents

7.4.4.2.1. NicheStack Thread Priorities

Intel’s version of the NicheStack networking stack relies on the MicroC/OS-II operating system’s threads to drive two critical tasks to properly service the networking stack. These tasks (threads) are tk_nettick, which is responsible for timekeeping, and tk_netmain, which is used to drive the main operation of the stack.

When building a NicheStack-based system in the Nios® II EDS, the default run-time thread priorities assigned to these tasks are: tk_netmain = 2 and tk_nettick = 3. These thread priorities provide the best networking performance possible for your system. However, in your embedded system you might need to override these priorities because your application task (or tasks) run more frequently than these tasks. Overriding these priorities, however, might result in performance degradation of network operations, as the NicheStack networking stack has fewer processor cycles to complete its tasks.

Therefore, if you need to increase the priority of your application tasks above that of the NicheStack tasks, make sure to yield control whenever possible to ensure that these tasks get some processor time. Additionally, ensure that the tk_netmain and tk_nettick tasks have priority levels that are just slightly less than the priority level of your critical system tasks.

When you yield control, the MicroC/OS-II scheduler places your application task from a running state into a waiting state. The scheduler then takes the next ready task and places it into a running state. If tk_netmain and tk_nettick are the higher priority tasks, they are allowed to run more frequently, which in turn increases the overall performance of the networking stack.

Note: If your MicroC/OS-II based application tasks run with a higher priority level (lower priority number) than the NicheStack tasks, remember to yield control periodically so the NicheStack tasks can run. Tasks using the NicheStack services should call the function tk_yield(). If they do not use the NicheStack services, the tasks should call the function OSTimeDly().