Is it possible to build a real time system without using real time operating system (RTOS)?
Technically it is possible to build a real-time system without using a real-time operating system (RTOS), but it can be more challenging and requires careful design and implementation.
In a real-time system without an RTOS, the software is typically designed to use interrupts and timers to handle events and inputs with specific timing requirements. The code must be carefully structured and optimized to minimize processing time and ensure that critical tasks are executed on time.
There are some alternative to build a real-time system without RTOS include:
- Cyclic executive. Cyclic executive is a simple scheduling technique that is suitable for small and relatively simple systems with fixed and predictable requirements. In a cyclic executive, tasks are scheduled to run in a fixed order, with each task being given a specific time slice in each cycle. Cyclic executives are easy to implement, but they have limited flexibility and scalability. They may not be suitable for larger or more complex systems with dynamic requirements or varying priorities.
- Bare-metal programming. This involves writing code directly for the microcontroller or processor without using an operating system. This approach can be fast and efficient, but it requires a deep understanding of the hardware and low-level programming skills.
- Cooperative multitasking; In this approach, tasks are scheduled to run cooperatively, meaning that they voluntarily yield the processor to other tasks when they are done. Cooperative multitasking can be simpler than using an RTOS, but it may not be suitable for systems with strict timing requirements or tasks with different priorities.
- Interrupt-driven programming; This approach uses interrupts to handle events and perform tasks, instead of relying on a scheduler. Interrupt-driven programming can be fast and efficient, but it may be more difficult to maintain and debug.
One approach is to use a bare-metal firmware, which is a minimal software layer that provides basic hardware abstraction and implements the real-time behavior directly in the code. Bare-metal firmware can be highly optimized for specific hardware and real-time requirements and can provide fast and predictable performance.
If a full RTOS is to big for our application, another approach is to use a small RTOS which is also known as lightweight real-time kernel or scheduler. Lightweight real-time kernel is a simplified version of an RTOS that provides basic scheduling and synchronization capabilities without the overhead of a full RTOS. Lightweight kernels can be easier to implement than full RTOSes and can be a good compromise between real-time capabilities and simplicity.
Some popular examples of lightweight real-time kernels include:
-
FreeRTOS: FreeRTOS is a popular open-source LWKernel that is widely used in embedded systems. It provides a small set of kernel services, including task scheduling, synchronization primitives, and inter-task communication.
-
uC/OS-II: uC/OS-II is a commercial LWKernel that provides a small set of real-time services, including task management, semaphores, and message queues. It is widely used in industrial and medical applications.
-
ChibiOS/RT: ChibiOS/RT is an open-source LWKernel that is designed for small embedded systems. It provides a small set of kernel services, including task scheduling, synchronization primitives, and inter-task communication.
-
RIOT: RIOT is an open-source LWKernel that is designed for low-power wireless embedded systems. It provides a small set of kernel services, including task scheduling, synchronization primitives, and inter-task communication.
However, using an RTOS can provide many benefits in terms of ease of development, code reusability, and scalability. An RTOS can provide a standardized and well-tested framework for real-time system development and can make it easier to manage complex systems with many tasks and inputs. Ultimately, the choice of real-time system architecture depends on the specific requirements and constraints of the system being developed.
Glossary
- Bare metal application is a firmware application intended to run without an operating system (OS)
- A real-time system is a system that must respond to events or inputs within specific time constraints.
- Operating Systems is a program that control the execution of application programs, and acts as an interface between applications and the computer hardware [Stallings, 2018]
- A real-time operating system is any operating system that provides a deterministic way of executing a given piece of code. [Stallings, 2018]
References
- Bare Metal Overview
- FreeRTOS
- uC/OS-II
- ChibiOS
- Wikipedia: Cyclic executive
- William Stallings, Operating Systems, Internals & Design Principles, Pearson 2018,