Real-time operating systems (RTOS) are a great tool for developers that are looking to decrease complexity associated with timing requirements in a real-time application. They provide developers with

  • a way to break-up their applications into smaller problems
  • improve robust and reliability
  • application predictability
  • multitasking
  • scalability

Sometimes though understanding the resources that are being allocated to an RTOS can be difficult to determine. That’s why with the Synergy platform, developers can use the RTOS Resources tab to glimpse behind the RTOS curtain and see how the RTOS is performing.

There are several different RTOS Resource tools available within e2 Studio. Synergy developers can find the one they are looking for during a debugging session by clicking Renesas Views -> Partner OS -> RTOS Resources. The first view that a developer will see is an option to select the RTOS as shown below:

The Synergy Platform uses ThreadX so pressing OK will reveal the default stack view below:

At this point, a developer would be ready to run their application by pressing resume. It’s important to note that the RTOS Resources tab does not refresh in real-time but collects data in the background. In order to see whether there are any threads and what their status is, a developer has to halt program execution. Halting execution will update the view to something like the following:

The thread tab has some useful information to tell a developer such as

  • How many threads are in the application
  • Thread name and entry function
  • The current threads current status such as RUN, SLEEP, Not created
  • What caused the thread to suspend, halt or be blocked
  • The thread priority
  • RunCount

With this information, a developer can start to get a glimpse into how many times their thread has executed. What other information might be useful though?

As the reader has probably already noticed, there are several different tabs that can be used to explore how ThreadX is using resources in the system. These tabs include:

  • Stack – which provides stack size and usage for each task
  • MessageQueue – lists the message queues in the application and their states
  • CountingSemaphore – lists the semaphores in the application and their count
  • EventFlag – lists the event flag groups in the application and their current value
  • MemoryBlockPool – the memory blocks in the application and their current allocation
  • System – general system information such as heap location

Just to name a few. The RTOS Resources tab can be used to determine how much stack space is required to run a thread and even help a developer perform a worst-case stack analysis. For example, in order to size a thread stack appropriately for the Blinky Thread, a developer can run their application with the RTOS Resources tab open and run through all their test cases that should push the thread to its limits. Upon completion, the application can be halted and under the Stack tab, all the stack usage statistics will be available for every thread in the application. An example can be seen below:

In this example, it can be seen that the maximum stack usage in bytes for Blinky thread was 232 bytes! The size allocated to that stack was 1024 bytes. The stack for Blinky thread was oversized by more than 400%! A developer doesn’t need to guess at their stack usage anymore but instead can now make an intelligent decision on how large to make the stack. In this case, using 512 bytes would probably still be overkill and something closer to 384 or less would be more appropriate. Why not 232? It’s possible that we truly didn’t hit worst case and in the field, we want to have a little extra room just in case. Sizing 20 – 30% larger helps to provide a little extra buffer to prevent a stack overflow. It’s better to be safe than sorry.

In the next post, we will discuss the different debug interfaces that are available on Synergy microcontrollers and begin to look at the capabilities that are available on S3, S5 and S7 devices that have an ETM available on them. Spoiler Alert! We going to start looking at statistical profiling, instruction tracing and verification.

Until next time,

Live long and profit!



Hot Tip of the Week: Check Out the New Synergy Enterprise Cloud Toolbox

There are some new documents for the Synergy Enterprise Cloud Toolbox you should take a look at. The accompanying application helps you to quickly get started on the Synergy Software Package (SSP), Wi-Fi Framework, Ethernet connectivity, and cloud connectivity with different IoT Cloud Providers using the Renesas Synergy™ Enterprise Cloud Toolbox.

The application uses NetX™ Secure and NetX™ MQTT to communicate with Amazon Web Solutions (AWS), Azure, and Google IoT Cloud Providers. The application showcases how to integrate functionality of the on-board sensors including accelerometer, barometric pressure sensor, temperature, and humidity sensor, and send this sensor data to the cloud over Ethernet or Wi-Fi network interfaces. How to send commands from the cloud to devices in order to turn an LED ON or OFF is also shown. Check it out with the below links!

Synergy Enterprise Cloud Toolbox Application Note

Synergy Enterprise Cloud Toolbox Project

Getting Started for AE-Cloud1

Getting Started for PE-Cloud1