Real-time OS [essential for MCU development]

What is a real-time OS?

An operating system (OS) is the basic software that manages and controls the entire computer system.
You may have heard of Microsoft Windows, Google's Android, Apple's iOS, and the open source Linux used in PCs, smartphones, and tablets. These are called general-purpose operating systems.

Operating systems (general-purpose OS and real-time OS)

Users of PCs, tablets, and other devices need only know how to use applications thanks to hardware such as CPUs and memory and a general-purpose OS when using application PCs and smartphones, and need not be aware of hardware such as PC mechanisms. The size of the OS is large because it incorporates many functions such as communication protocols and graphics for screen display.

In a general-purpose OS, applications are switched every allotted period of time in a method called round-robin scheduling, so even if a task needs to be processed immediately, it must wait until another task is running to complete. For this reason, it is not suitable for controlling hardware that strictly manages processing time.

General-purpose OS

The OS used in embedded systems is called a real-time OS (Real Time Operating System), which can predict processing times and adjust the order of processing in order of priority to strictly adhere to processing times, with emphasis on response speed with real-time performance.

Each process to be executed is called a task (thread), and task scheduling is performed by setting priorities for multiple tasks. This is called task priority scheduling. Since it has the minimum necessary functions to control hardware, it is small in size and light in weight.

Real-time OS

Why Use a Real-Time OS in Embedded Applications?

When an application has multiple functions and processes, it is difficult to meet specifications by simply executing processes sequentially as usual. Some processes need to be executed more frequently while others need to be executed less frequently. Some processes are more urgent than others, and some processes, such as display, can be put off until a later time.

For urgent processing, interrupt processing must be used frequently in addition to normal processing, but a program in which multiple interrupts account for the majority of processing is not reliable from the standpoint of system stability. It is difficult to configure a program with only interrupts that have different priorities and frequencies.

This is where a real-time OS comes in. A real-time OS handles processing in units called tasks, and priority and processing frequency (intervals) can be set. It is also easy to switch tasks within an application, enabling or disabling tasks as needed.

By utilizing a real-time OS, complex, multiple processes can be written in a simpler and more systematic manner than when interrupt processing is not used, making development easier and more effortless.

This site will take up and explain some of the combination of FreeRTOS and STM32 applications as an introduction to real-time OS. In particular, multiple task management methods and queues are explained in detail.

The detailed usage and settings of a real-time OS vary depending on the type of OS and MCU, so it is necessary to update your knowledge of real-time OSs from time to time. However, the basic concepts available in a real-time OS are the same regardless of the type of OS or MCU, so please try to grasp the program flow when using a real-time OS here.

Although there is some initial trial and error involved in building a program using a real-time OS, once completed, it can be easily applied as a template.

FreeRTOS is already configured for MCU of the educational material board used on this site. You can use the real-time OS right away and check its operation, so please use the real-time OS at the same time as learning MCU.

Follow me!