FreeRTOS is an open-source, real time operating system for microcontrollers/Embedded devices which allows devices to execute multiple processes at the same time. Let’s quickly discuss difference between OS (Operating System) and RTOS (Real-time Operating System) before digging deep into the topic for better understanding.
Operating System:
Operating System is a program that is responsible for managing all software resources and provide common services for computer programs most common operating systems are Microsoft Windows, Apple’s iOS, Google’s Android OS, Apple’s macOS and Linux OS. Following are the popular types of OS:
- Batch Operating System
- Multitasking/Time Sharing OS
- Real-Time Operating System
- Distributed Operating System
- Network Operating System
- Mobile Operating System
Real-Time OS:
Real-time Operating system is type operating system commonly used in Microcontrollers/Embedded devices. Popularity of RTOS in Embedded Systems is due to its predictable and deterministic behavior results in fast and real time response to the events than operating systems as Windows or UNIX, but Real-Time OS does not provide advance graphical interfaces, web browsing and other familiar features.
There are three types of Real Time Operating Systems hard real time, Firm real time, and soft real time. Most popular Real-Time Operating Systems are DeOS, embOS, FreeRTOS, Neclues, Keil RTX and Zephyr.
Introduction to FreeRTOS
FreeRTOS is one of the most popular classes of Real Time OS, it is concise, fast, and compatible with microcontrollers which enable it to be used in embedded applications. Most frequently asked question is “Is FreeRTOS Free” yes, it is. It is an open-source software under MIT license and supports almost 40 microcontroller architectures including ARM and RISC-V. FreeRTOS written in C language which is already adapted and popular in industry.
Multiple programs can be executed at same time, FreeRTOS schedule multiple tasks in accordance with their priority and facilitate intercommunication of two or more independent tasks. A simple FreeRTOS example is given bellow:
Queues are responsible for intercommunication of two or more independent tasks, for example a value in task 1 is required in task 2 for decision making or some other purpose queues can be really helpful in these types of scenarios.
FreeRTOS Features
- Easy-to-use: Written in C language and easy to use and adaptable
- Mutex and Semaphore: Providing Mutex and Semaphore for better resource handling
- Memory Management: Effective Heap management
- Configurable Kernel: you can configure its kernel for a specific board and application
- Software Timers: Software timer allows a function to be executed at a set time in the future
- Tasks and Queues: You can create independent tasks and queues facilitate intercommunication of tasks
- Stack Overflow protection: Callback functions to take necessary actions upon detection of a stack overflow
Benefits of FreeRTOS
1. Open-Source
Released under open-source MIT license, It is free to use, secure and robust real time operating system
2. Small Size
FreeRTOS is concise in size. Due to its small size, it is compatible with microcontrollers and is being widely used in the embedded systems industry. Even Small controllers with limited RAM and flash storage can FreeRTOS. Obviously, advanced graphics, web browsing, and other familiar features are not provided by FreeRTOS as it is designed to be small, fast, and adaptable by microcontrollers.
3. Responsive and Fast
FreeRTOS is more responsive than any other OS like windows OS, mobile OS etc. It respond to any external event very rapidly and capable to entertain events by user in real time.
4. Long Term Support
FreeRTOS released its LTS version 202012.00 LTS. FreeRTOS will release LTS versions of its OS including feature stability, bug fixes and security patches for almost two years from release dates.
5. Ecosystem Support
FreeRTOS partner ecosystem provide its users access to number of resources like professional support, community contributions, IDE, and productivity tools. FreeRTOS provide flexible, configurable and support variety of architectures, almost 40, which are compatible with significant number of microcontrollers. You can find Freertos explained with Freertos example code on GitHub and Freertos example project and setup details easily.
FreeRTOS Applications
Embedded Systems industry use FreeRTOS for a wide range of applications providing services in many sectors. Some of FreeRTOS application areas are:
- Internet of Things
- Industrial IoT
- Medical Sector
- Complex Multimedia Systems
- Traffic control systems
- Automation
- Robotics
- Industrial Equipment
- Smart Home appliances
- Domestic and Industrial Energy monitoring solutions
How To Download
Step 1. Go to FreeRTOS website.
Step 2. Click on download button.
Step 3. Before selecting your required version kindly read the official documentation in the website.
Step 4. Click on download and unzip your file after downloading.
Step 5. Read usage guide carefully to install the software.
Challenges in RTOS
Synchronization:
Synchronization is one of the common problems in RTOS, multitasking is provided by RTOS, but synchronization is these tasks is very important in case where data is distributed and computed by different tasks but share same destination if tasks are not synchronized there will be errors and result will be unexpected and inaccurate.
Resource Management:
Handling resources is the most critical part of RTOS. In case of bad memory management whole system could crash due to deadlock conditions. Developers must be very careful when deleting, resuming, or blocking any tasks. Mutex and Semaphores should be handled very carefully.
Setting Priority:
Setting priorities of tasks is important, system could be slow or provide unexpected results if priority of tasks is not correctly provided.
Debugging:
Debugging in RTOS is also a big challenge. Priority inversion, deadlock, race condition, and other critical issues are introduced with the multitasking capability of RTOS. To design and debug real-time operating systems, sufficient knowledge of OS and RTOS is required.