Product Information
Community and Support

RT State Checker

One of the most important features of the RT kernel is the State Checker, a debug feature that can be enabled by setting CH_DBG_SYSTEM_STATE_CHECK to TRUE.


One of the most common problems while using an RTOS is making sure that RTOS services are invoked from the proper context and/or system state.

Not all RTOS functions can be called from any context, for example, it makes no sense to invoke from an ISR a function that puts to sleep the current task/thread.

Usually RTOS functions include in the documentation the proper way and place to invoke them, the problem is that the thing is documented and not actually checked by the system.

The problem is exacerbated by the fact that this kind of errors often do not result in a clear malfunction but could cause rare and inexplicable crashes or malfunctions in the application.

State Checking

When the State Checker is enabled the system state is checked each time an RTOS function is called at runtime, in case of violation the system is halted with an error code that can be retrieved using the debugger.

More details about ChibiOS debugging are available in the Debugging Guide.


The State Checker ensures that a whole class of very common errors related to RTOS use are found at development time. This greatly increases the odds that the final application code is as errors-free as possible.

The point is to not let such errors go unnoticed, if the applications runs with State Checker enabled then there is a high level of confidence that the RTOS use is correct. Just a note, the other class of common errors are stack overflows, the system offers support also for detecting those at development time.

More articles and guides are available on the technical wiki.

learn more

Need Tutorials?

Try the video tutorials and guides on Play Embedded.

learn more

Need Support?

The forums is the best place, registration required.

learn more