Thread Stack Usage
- Kelvin Lawson
- 2010-03-01 @ 23:34
I have just committed changes to the RTOS to support analysing the stack
usage of your threads.
You can call atomThreadStackCheck() at runtime to get an indication of the
high water mark within a thread's stack (the furthest modified point from
the start of the thread's stack allocation). There is a slight overhead
associated with this feature (larger TCBs, additional CPU cycles during
thread creation) so it is only enabled if ATOM_STACK_CHECKING is defined. I
recommend that this feature is used during development and disabled in
All of the automated test modules now take advantage of this feature - any
threads created within the automated test suite are checked for stack
exhaustion, raising further the level of confidence that can be gained from
using the suite when creating ports to new architectures.
Note that this has necessitated a slight change to the atomThreadCreate()
API, which now has a new parameter for passing in the stack size.
The changes are now in Github, and have been tested on ATmega16, ATmega32
and STM8S platforms.