Using Highwatermarks for Memory and Resource Optimization


The OSAL implementation for RL-ARM contains a mechanism called "highwatermarks" to analyze the maximum usage of system resources like events and timers during runtime. Using the Debug buildset with the define WST_HIGHWATERMARKS_ENABLED set in the RXF library project and your application project, you can inspect the variable WST_Highwater in RiCHighwater.h with a debugger. It will show details for the following size values which are part of the WST_Highwater_t structure:

maxUsedTimersMaximum number of timeouts used.
timeoutsInUseCurrent number of timeouts used.
minMemoryBlocksSmallest value of available memory blocks for events and timers which has been reached.
mbx[]Array to keep track of the free message queue memory.
mbx_isr[]Array to keep track of the free message queue memory used from interrupt service routines.

Note: The define WSTHighwatermarks_MAX_TASKS has to be set up by the user per project, as it is not possible for our source to automatically dimension the message queues array. The default value we deliver is 7.

You can view the values of the highwatermarks structure inside the Keil uVision Watch-Window after adding "WST_Highwater" to it:
Watch Window Sample

Timers and the value "minMemoryBlock" are system-wide, but mbx and mbx_isr are available in an array, as they have an instance per task. A value of "0xFFFFFFFF" for a task's freeMemory means this active task has not yet consumed memory for the message queue.



Copyright (c) Willert Software Tools GmbH. All rights reserved.