6 Tips for Robust and Flexible RTOS Architecture Development

RTOS stands for “real-time operating system.” These systems control devices such as sensors or actuators. They also provide services such as messaging, scheduling, and security.

The development of these systems requires a great deal of expertise. This article provides some helpful information regarding the design of robust and flexible RTOS architectures.

Contents

What is RTOS?

As alluded to above, RTOS is an operating system (OS). The key difference between RTOS and other operating systems like Windows and macOS is that it processes or responds to incoming data in real-time.

What exactly does that mean? The operating systems most of us are familiar with run on mobile phones and personal computers. These are comparatively bloated with applications and features and use a lot of memory. They are designed to support what the user wants to do at any given time.

In contrast, RTOS is streamlined and designed to execute small tasks as quickly as possible and effectively. It’s also a fraction of the size of an OS used on a computer and boasts a simple graphical interface.

Real-time systems are essentially time-bound systems with strict timing requirements and constraints. As such, the processor will complete each task within its given time constraint to ensure the timely execution of the following tasks. Whenever it doesn’t manage to do it, the system fails.

A robust RTOS system will be able to maintain strict time constraints and optimize multitasking. You can find RTOS running on devices like defense systems (radar), air traffic control systems, medical devices (pacemakers), and networked multimedia systems.

Now that we got that out of the way let’s dive into the top 6 robust and flexible RTOS architecture development tips.

Tips for RTOS architecture development

1. Eliminate Application Dependencies

RTOS developers tend to select their preferred RTOS and then develop their software architecture based on it. However, while this approach may seem straightforward at first, it can quickly become a nightmare.

For example, it can be pretty challenging to maintain or port that code to another application with a different RTOS. There are almost 100 different RTOSs with their own Application Programming Interface (API). This means that switching the RTOS will demand each RTOS API call to be found and changed, making it a time and resource-intensive endeavor.

The best approach here is to design the application agnostic to the RTOS. As they all have similar functionality, placing the RTOS behind the Operating System Abstraction Layer (OSAL) won’t be too difficult to decrease application RTOS dependence and improve flexibility.

2. Minimize Application Tasks

The key to building robust and flexible RTOS architecture is to break down an application into little tasks. In this scenario, these mini-programs can run concurrently, making the whole process much more straightforward.

However, it’s important not to create more tasks than what’s required to run the application. This is because each task demands the creation of a Task Control Block (TCB), which will manage that task, requiring more memory to function effectively.

3. Leverage an Outside-in Technique to Define Initial Tasks

Use an outside-in approach to define tasks. This approach helps RTOS developers look at the entire system and break it down into application-related tasks, physical features, and more. In this scenario, the resulting tasks usually take the form of input processing, memory management, network management, and printing.

RTOS developers can also use this technique to decide what tasks need to be added and what can be left out. There is usually more than one way to build a task, so this technique can also help ascertain the best way forward.

RTOS architecture

RTOS Architecture 

4. Define Task Priorities with Rate Monotonic Scheduling (RMS)

Once defining the initial tasks in the RTOS architecture, it will help to use RMS to determine if the task design is doing what was intended. In this case, developers can also ask themselves questions like, “can all these tasks be executed in a timely manner?

RMS can also prioritize tasks. Just create a table with the sum utilization and make sure that CPU utilization is less than the list value. For example, if you want the system to execute five tasks, the CPU utilization must be less than 0.743 to schedule those tasks.

5. Use a Dataflow Diagram

Create a data flow diagram to better understand how your data flows through the application. This single high-level application picture shows the data generation points, how it moves from generation to consumption, where it’s stored, and how it’s accessed.

The dataflow diagram often shows tasks, event flags, queues, semaphores, and mutexes protecting shared data. This approach comes in handy when pushing the code and testing the architecture.

6. Define the Task and Message Interface

Once the dataflow diagram is complete, developers will be itching to start coding. However, this is a bad idea as you will probably end up spending a lot of time rewriting the code if they don’t first take the time to define the task and message interfaces.

This is because the dataflow diagram only shows how data propagates through the application. You rarely have to define the data structures. So, it’s critical to examine each message queue upfront before building the data structure for those messages.

From a design perspective, it’s also important because it has an impact on what the messages look like and how the interfaces for each underlying module look. Although there isn’t a formula or a turnkey solution to do this, understanding how these messages move around will help build the interface for modules that support task execution. It’s the best approach to understanding the application you’re going to develop and its components.

The Bottom Line

As you can see from the above, developing RTOS is similar to developing software architecture for computers and mobile devices, but on a smaller scale and with real-time dependencies. Although this article scratches the surface, it’s an excellent place to start. 

Looking for a technology partner?

Let’s talk.

Related Articles