The OS shall provide a stack monitoring which detects possible stack faults of Task(s)/Category 2 ISR(s). [SWS_Os_00067]
Stack Check Strategy
All OS stacks must be protected from overflowing. The OS shall offer different strategies to detect stack overflows or even to prevent stacks from overflowing.
In dependency of the configured scalability class there are the following strategies:
Scalability Class | Stack check strategy | |||||||||||
SC1 / SC2 | Software stack check (see below) | |||||||||||
SC3 / SC4 | Stack supervision by memory protection unit (MPU) (Refer to "OS-Memory Protection") |
How to detect a stack overflow (Software stack check)
The use of stack monitoring is specified by OsStackMonitoring at the time of configuration.
There are three methods for detecting stack overflow.
- Stack pointer check method
- Magic number check method
- Stack remaining amount check method
The situation in which stack overflow can be detected differs depending on each method. Due to the specifications of each method, the stack monitoring function of the OS cannot always detect stack overflow.
Stack pointer check method
The stack pointer check method is a method