Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



This set of commits adds support for thread runtime stack safety. It has been divided into two parts--kernel support and thread analyzer integration.
On the kernel side, this extends the idea of the existing k_thread_stack_space_get() to invoke a caller defined handler/callback if the amount of unused stack space is less than a configured threshold. Two new stack checking routines have been added: k_thread_runtime_stack_safety_full_check() and k_thread_runtime_stack_safety_threshold_check(). The latter performs an abbreviated check on the stack that is limited to the configured threshold.
On the thread analyzer integration side, when enabled it replaces the stack check with the full stack safety check. The default handler can be replaced at runtime by calling thread_analyzer_stack_safety_handler_set(). This allows a developer to leverage the existing analyzer to periodically scan stack usages and act upon them accordingly if their configured thresholds have been crossed (log the incident, suspend a thread, abort a thread, reboot the system, ...).