Can a microcontroller run an operating system?

Publisher:dst2015Latest update time:2023-03-14 Source: zhihu Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Let’s get straight to the answer first: Yes!

However, the operating system is not strictly necessary . The operating system takes up more resources of the microcontroller, such as FLASH and RAM, which indirectly increases the hardware cost. Even if the cost increases by 1 cent, for high-volume products, every minute is an engineer's salary. .

I have been developing microcontrollers for more than 10 years. Most of the products are actually programmed with bare metal, and relatively few use operating systems.

Of course, this is related to product functions. Generally, products with complex functions and demanding real-time requirements will use the operating system.

Currently, the most commonly used real-time operating systems are uC/OS-II, FreeRTOS, and rt-thread.

Below, I will briefly explain to you the advantages and disadvantages of the three systems. Please correct me if there is anything wrong!

1. uC/OS-II

uC/OS-II is a commercial real-time operating system developed by Micrium. Its kernel design is very stable and reliable. It pays more attention to the richness of scheduling algorithms and system services, and is suitable for applications that require higher real-time performance and stability.

The advantages and disadvantages of uC/OS-II are as follows:

Features:

Development friendly: lots of information.

Real-time performance: uC/OS-II can provide very fast interrupt response and task switching to ensure real-time performance of the system.

Portability: uC/OS-II can support a variety of different processor architectures, making applications easier to port to different hardware platforms.

Reliability: Because the kernel design of uC/OS-II is very stable and reliable, it is widely used in a variety of embedded systems.

Mature ecological environment : Since uC/OS-II has been released for a long time, its community and ecological environment are very mature and complete, and users can easily obtain documentation, examples and support.

shortcoming:

Commercial license fee: uC/OS-II is a commercial real-time operating system, and users need to purchase a commercial license to use it.

Resource occupation: uC/OS-II occupies a lot of microcontroller resources and requires large storage space and memory space.

In addition, developers can tailor it, which means you can modify the system code to customize it according to the functions of your product. The premise is that you have a thorough understanding of the system code. Otherwise, don't try it easily, otherwise it will be easy to dig a hole for yourself.


2.  FreeRTOS

FreeRTOS is an open source real-time operating system with a high market share.

Features:

Commercial licensing fee: free for commercial use

Lightweight: The kernel of FreeRTOS is very small and suitable for resource-constrained microcontrollers.

Real-time performance: FreeRTOS can provide very fast interrupt response and task switching to ensure the real-time performance of the system.

Portability: FreeRTOS can support a variety of different processor architectures, making applications easier to port to different hardware platforms.

Community support: The FreeRTOS community is very active, and a large number of developers participate in development and maintenance, making the FreeRTOS ecological environment very complete.

Good documentation and materials: FreeRTOS has very rich documentation and materials, and it is relatively simple to learn and use FreeRTOS.

shortcoming:

Few components: Some functional components are not perfect enough, such as GUI (graphical interface), TCP/IP, and file systems that need to be expanded to third parties.


3. rt-thread

This is a domestic real-time operating system suitable for IoT products. It is characterized by extremely low resource usage (1.2KB RAM and 3KB Flash), and the code structure is more convenient for low-power functions.

advantage:

Lightweight: The core of RT-Thread is very small and suitable for resource-constrained microcontrollers.

Real-time performance: RT-Thread can provide very fast interrupt response and task switching to ensure the real-time performance of the system.

Tailorability: RT-Thread can select the required components as needed to reduce the resources occupied by the system.

Object-oriented: RT-Thread supports object-oriented programming, making the code clearer and easier to understand.

Cross-platform support: RT-Thread can support many different processor architectures.

shortcoming:

The ecosystem is relatively incomplete: Compared with some mature embedded operating systems, RT-Thread has a relatively small number of communities and developers, and the ecological environment is relatively incomplete.

The learning curve is steep: RT-Thread is a relatively new operating system with relatively few documents and information, and the learning curve is relatively steep.

Not suitable for large-scale systems: Since RT-Thread's kernel design is originally designed to be lightweight and real-time, it is not suitable for building large-scale embedded systems.


4. My own understanding of RTOS

Finally, let me talk about my understanding of these real-time operating systems.

I think a real-time operating system is essentially a program architecture with high real-time performance .

Real-time is to ensure that my task is executed within the specified time, which cannot be achieved using the traditional while(1) polling method.

The program architecture is like the foundation when building a house. Only when the foundation is stable can it cope with the impact of harsh external environments on the house, such as typhoons and earthquakes.

The same goes for when we write programs. The program architecture is the "foundation". Only when the foundation is stable can your program be able to cope with the sudden changes in functions and chip changes made by the project manager. Only then will your code be able to withstand the twists and turns and the product functions will be stable. .

Unfortunately, many engineers do not have the ability to write program architecture because the requirements for experience and coding level are strict.

Therefore, for generally complex projects, just use a ready-made, stable real-time operating system.

This can guarantee at least two things:

1. There is no problem with the program structure.

2. There is no problem with the real-time nature of the program.

However, there are disadvantages to using ready-made ones, that is, RTOS has many functions, many of which your product cannot use at all, but you have no choice and you don’t know how to tailor them, which will waste a lot of your microcontroller resources.

So in the past few years, when I was doing projects, I always used the program structure I wrote myself, and then the real-time nature of the program was avoided manually.


Reference address:Can a microcontroller run an operating system?

Previous article:What is the difference between FLASH and EEPROM during microcontroller development? How to choose?
Next article:Can a microcontroller achieve true multi-threading?

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号