...
The statistic task is optional in a µC/OS-III application and its presence is controlled by a compile-time configuration constant OS_CFG_STAT_TASK_EN
defined in os_cfg.h
. Specifically, the code is included in the build when OS_CFG_STAT_TASK_EN
is set to 1 DEF_ENABLED
.
Also, the priority of this task and the location and size of the statistic task’s stack is configurable via OS_CFG_STAT_TASK_PRIO
declared in os_cfg_app.h
().
If the application uses the statistic task, it should call OSStatTaskCPUUsageInit()
from the first, and only application task created in the main()
function as shown in Listing 5-5the listing below. The startup code should create only one task before calling OSStart()
. The single task created is, of course, allowed to create other tasks, but only after calling OSStatTaskCPUUsageInit()
.