Graphical Visualization of the Internal Behavior of an RTOS [don't just see half the picture]

Posted by Magnus Unemyr on May 10, 2017 11:08:11 AM

Debugging RTOS-based applications often introduce new complexities. In this blog post, I will reveal a trick that can give you completely new insights into the system as you debug it.

Have you ever plotted the internal behavior of an RTOS graphically, live in real-time? If you haven’t, perhaps you should consider this powerful debug technique now. Read more to find out how!


Serial Wire Viewer (SWV) real-time event- and data tracing is arguably the most powerful debug capability of most Cortex-M cores. The Serial Wire Viewer’s capabilities for exact and accurate monitoring of memory accesses (variable updates) can be combined with real-time operating systems to provide a uniquely powerful tool for advanced visualization and debugging of middleware-equipped embedded systems.

By combining the SWV real-time data plot graph capabilities in Atollic TrueSTUDIO Pro with real-time operating systems, valuable RTOS-specific internal system variables can be monitored and visualized in real-time.

An example is displayed in the screenshot below, where SWV has been configured to monitor an RTOS-internal variable (the number of messages in a mailbox/message queue in this case) in real-time. The oscilloscope-styled data plot graph (that is updated live in real-time) reveals the pattern of the number of messages in the mailbox over time.

Presented as a graphical pattern, it becomes very easy to see if there are any unexpected problems, like the mailbox sometimes growing unexpectedly (because the reader task do not extract messages as expected) or perhaps not being filled according to the expected pattern (for example, because of a bug in the writer task).

RTOS-aware debug with live data trace

The screenshot above shows how easy it is to get a good insight into what happens with an RTOS mailbox/message queue over time, when you can present this data graphically using the SWV data plot graph. The same technique can be used to visualise many other types of RTOS-internal data as well - provided the RTOS expose this data as an accessible RTOS-internal variable.

For example:

  • Visualize the CPU load; either of the complete system or a particular task
  • Visualize the number of tasks
  • Visualize the value of a counting semaphore
  • Visualize the number of messages in a message queue
  • Visualize the value of a timer
  • Visualize the enumerated state of an RTOS object, for example if a task is running (0), ready (1), blocked (2), or suspended (3)

Being able to monitor key RTOS-internal system variables in real-time adds a completely new level of debug power not previously available. With this capability, RTOS-based embedded systems can be debugged using a completely new set of visualization tools for tricky RTOS-related bugs.

Read the superset blog post that covers the entire topic of Cortex-M debugging:

How to use the most powerful debug techniques on ARM Cortex-M devices

You can also get a good overview of Serial Wire Viewer real-time tracing on Cortex-M cores by reading this white paper on the subject:

Read our SWV event and data tracing whitepaper!

Topics: Debugging, RTOS, SWV