RTOS Design and Debugging Techniques Hands-on
Real-time operating systems (RTOS) have found their way into nearly every embedded system. The problem though is that an RTOS can often complicate implementation, increase module coupling and make debugging a nightmare.
In this workshop, Jacob Beningo will walk attendees through RTOS implementation and debugging techniques that will help developers accelerate their design cycle and implement more robust and flexible design techniques. Attendees will learn hands-on about topics such as:
- How to initialize tasks
- How to properly set task stack size and monitor for stack overflows
- Decouple application code from the RTOS
- Properly protect shared resources
- Minimize response time for system events
- Perform application tracing and performance analysis
Additional topics and details about specifics boards and RTOS will be provided closer to the conference.
Why does Jacob Beningo recommend using a centralized task configuration table when creating RTOS tasks?
Great workshop! I particularly liked your suggestion to initialize tasks from a table (mine are all over the place...) and the intro to Tracealyzer. It looks amazing - I just wish it was more affordable for the node-locked license.
Thanks! I've found it to help organize tasks.
"Just a consultant?". Seems to me that you have provided a valuable service to the embedded community with your talks, books, involvement in this conference, etc. Thanks Jason.
Thanks!
Hi Jacob, this one got lost in the queue in the session. Can you comment on the proper STM32 configuration for interrupts related to scheduling? Specifically the priority of SysTick and PendSV as well as as the HAL's tick increment method. I've heard differing opinions... not sure I've seen a solid answer yet.
Thanks for posting it and sorry for the delay!
The short answer is, it depends on your application.
General rule of thumb that I use is to set the SysTick to a high priority since it is the primary time manager for the RTOS. PendSV is typically used by the RTOS to perform a context switch. It is generally the lowest priority interrupt.
For the HAL time tick, I typically choose a priority less than SysTick, greater than PenSV. I look carefully at the other interrupts in the system and the response time requirements and then set it based on the system needs.
I hope that helps. Relatively generic answer but let me know if you have any follow-up questions / comments.
What is the best way to implement an application which has an inherent need for state control (i.e. state machine, controlled by driver inputs) in and RTOS design paradigm?
I have implemented an Event Handler which distributes messages from a Queue to the running context, but so far hasn't been deterministic.
Sorry for the delay! The conference kept me busy and I overlooked my messages.
Typically, I will design my state machine and then have a StateMachine_Run function that is called from the task. You can process your driver inputs and then feed it to the state machine. Like you mentioned, you lose some determinism and also may inject jitter. Jean Labrosse made a great comment that if your response times are ok, you can process your state machine on the previous dataset, then process the new driver inputs in order to minimize jitter.
How many is too many tasks? How can I decide whether or not to implement a task in, let's say, a peripheral driver?
My rule of thumb is to not have more than a 12 tasks that are grouped together. So for example, I may have 6 tasks that handle TCP/IP and web communications, 8 tasks that manage interactions with peripherals, 10 tasks that manage core application features, 4 tasks that manage optional application features, etc.
Technically you can have as many tasks as you want, but I like to build them out in logical groups of no more than 12, just so it?s easy to manage.
As far as peripheral drivers go, I would keep the RTOS out of the drivers. We want to keep a domain separation between between driver code, middleware and the application. An RTOS task can call a driver function, but try to keep them RTOS independent.
I hope that helps!













Well, I accidentally deleted the workshop files from Dropbox. So the link in the workshop recording will no longer work. However, I've reposted the materials to the following link: https://www.dropbox.com/s/4tn40bbopu8a4mf/EOC21-RTOS-Workshop_Labs.zip?dl=0