|
NetBurner 3.5.6
PDF Version |
This example demonstrates how to increase the maximum number of system tasks beyond the default limits in the NBRTOS (NetBurner Real-Time Operating System). The application creates multiple tasks that execute in a sequential chain pattern, showcasing the system's ability to handle an increased task count.
The MaxTasks example creates 64 additional tasks beyond the standard system tasks. These tasks operate in a coordinated sequence where each task:
The tasks execute in reverse priority order, creating a continuous cycle that demonstrates the system's task scheduling capabilities.
The application requires modification of default RTOS limits through the constants-overload.h file:
overload folder with the same path as the where the constants file is normally found, \nbrtos\include\constants-overload.h. The entire project path for constants is then: \MaxTasks\overload\nbrtos\include\constants-overload.hEXTRA_TASK_COUNT)MAIN_PRIO + 1 (configurable via EXTRA_TASK_BASE_PRIO)USER_TASK_STK_SIZE stack spaceuint8_t formatOSTaskID() return typeIncreasing maximum task priorities affects system performance in several ways:
A caution regarding system limits and performance. There is a hard limit of 256 task priorities in the NBRTOS. This is a function of storing the task priority in a uint8_t in the OS_TCB and the return type of OSTaskID().
As for the impact on system performance, when you increase the maximum task priorities, the OS must be able to handle the additional priority values. To do so, all task priority lists used in various OS related objects (i.e. OS_CRIT) have to grow in size. This not only means more memory usage, but, more fundamentally, more processing overhead. The processing overhead is twofold:
By default, most OS control objects (OS_CRIT, OS_SEM, OS_FIFO, OS_MBOX) are 16 bytes. This fits nicely from a memory alignment perspective as it's a power of two. By increasing the max priority value, it increases the size and breaks that symmetry, increasing the odds of the structure spanning multiple cache lines. Given this, the number of priorities shold not be increased unless absolutely necessary.
The application uses an array of semaphores (ExtraTaskSem[]) to coordinate task execution. Each task:
EXTRA_TASK_COUNTconstants-overload.h has appropriate OS_MAX_TASKS and OS_MAX_PRIOS valuesEach task prints information in the format:
Example output:
The application includes comprehensive error checking:
To modify the application:
EXTRA_TASK_COUNT to create more/fewer tasksEXTRA_TASK_BASE_PRIO to change starting priorityExtraTask() and UserMain()This example is primarily for demonstration and testing purposes. In production systems, carefully consider the performance implications of increasing task limits and only do so when the additional tasks are essential for your application's functionality.