RTOS stands for Real Time Operating System. It is an Operating System that is used in real-time applications such as medical critical care, defense and aircraft systems. This post will discuss RTOS (Real Time Operating System) in Embedded system, how it differs from OS, types, how it works, its uses, Architecture, Advantage and Disadvantages.
What is RTOS (Real Time Operating System)
RTOS is an Operating System that is used in real-time applications to obtain real-time output without buffer delay. To do multiple tasks without compromising on the synchronization in a short span of time is achieved by the Real Time Operating System (RTOS).
Fig. 1 – Introduction to RTOS
What is difference between OS and RTOS?
How A General Purpose Operating Systems (GPOS) allow multiple programs to execute at the same time. However, each processor can process a single thread (task) at a given point of time. All the general-purpose operating systems have the capacity to execute multi-tasks at the same time and it lacks in synchronization of the data.
In an RTOS, the processing time requirements are calculated in tenths of seconds or shorter increments of time. Real Time Operating Systems uses real-time constraints such as power time and effective utilization of memory. RTOS is a priority based operating system designed to serve real time applications. RTOS requires fewer resources in-order to provide accuracy of the task. It occupies less memory.
Fig. 2 – Real Time System with RTOS
The General Purpose Operating System is used in PCs and laptops whereas Real Time Operating System finds its application in embedded systems. Performance is a prominent factor required to be considered while selecting RTOS. The main advantage of a Real Time Operating System is it produces an accurate output within no time. The only disadvantage of RTOS is that the system only concentrates on a few tasks.
Types of RTOS (Real Time Operating System)
It is classified into three types. They are:
- Soft Real Time Operating System
- Hard Real Time Operating System
- Firm Real Time Operating System
1. Soft Real Time Operating System
In this type of Operating System, the response time of the system is prime but not critical to the operation of the system. It has a deadline specified but the system can accept a short amount of delay. Example: Online transaction system, Price quotation system, etc.
2. Hard Real Time Operating System
In Hard Real Time Operating Systems the deadline and the time duration to execute tasks are specified. It is necessary for a system to respond within the time line specified else might result in disastrous consequences. Example: Medical critical care systems, Aircraft systems, etc.
3. Firm Real Time Operating System
In Firm RTOS, the deadline is specified but missing it does not cause a big impact. Example: Multimedia applications.
Fig. 3 – Time Efficiency Curves of different RTOS
What is RTOS in Embedded System | Parameters for Selection
RTOS is used in Embedded Systems as it requires real-time data. For a Real Time OS to be functional, following parameters are to be considered:
- Performance: Performance is the most important factor required to be considered while selecting for an RTOS.
- Error-Free: An error-free RTOS performs an error-free task.
- Maximum Utilization: Maximum Utilization of the processor can be achieved with the assistance of the RTOS system.
- Task Shift: The time taken from shifting one task to another is less in RTOS.
- Middleware Support: Middleware support helps Real Time Operating Systems to reduce the time-taken integration of the process.
What is Kernel | Relevance of Kernel in RTOS Architecture
The core component of an operating system is called Kernel. Micro-Kernel Architecture is implemented in Real Time Operating System with configurable functionalities. Abstraction Layer is provided by the Kernel which offers six main types of common services to the Application software. They are:
- Task Management
- Task Scheduling
- Task Synchronization
- Memory Management
- Time Management
- Interrupt Handling
- Device I/O Management
Fig. 4 – Architecture of RTOS
The application is divided into small, schedulable, and sequential program units known as ‘Thread‘ or ‘Task‘. This is done to achieve concurrency in Real Time Application. Task Management by Kernel includes Real Time Task Creation, termination, changing priorities etc. Task creation involves creating a Task Control Block (TCB) which has information about Task id, priority, Task states i.e. if the task is in (idle, running, ready, terminated) state etc.
It records the state of each task and determines the task of highest priority, to be executed. The task which is already running is suspended and the processor executes the high priority task.
It is necessary for the information to be transmitted safely from one Task or Thread to another Task. Task Synchronization enables the tasks to mutually share the resources like buffers, I/O devices etc.
It allocates the memory for each program. There are two types of Memory Management for RTOS. They are:
- Stack Management
- Heap Management
To schedule the tasks that need to be executed during specified duration, there is need for a periodical interrupt. Hence hardware Timer is programmed to interrupt the processor. Time interrupt is called System Tick.
CPU is informed about any asynchronous event through an Interrupt. It is a hardware mechanism which handles an event by providing functions like defining Interrupt Handler, creation and deletion of Interrupt service routine etc.
Device I/O Management
Device I/O Management helps in providing uniform framework ( API – Application Programmers Interface). It also helps in accessing specific hardware device drivers i.e. it locates the right device for I/O request.
How does RTOS (Real Time Operating System) Work
Real Time Application requests are serviced by Real Time Operating System. The RTOS allows multiple tasks or programs to execute simultaneously based on its priority. Task scheduling Unit decides which thread is to be executed. The processor suspends the running task (if any) and executes the high priority task it receives.
Fig. 5 – Schematic Representation of Working of RTOS
Let us say, a user is browsing on the net and after few seconds switches on YouTube Video and in no time, the user starts listening to a Podcast. Browsing on the net is considered as ‘Task 1’, Video on YouTube is Task 2 and listening to Podcast is assumed to be Task 3. Switching between these tasks is called as Multi-Tasking and RTOS provides efficient multitasking services.
When the User shifts to Task 2, then Task 1 is terminated and executes Task 2 as its priority is High. Similarly, when the User shifts to Task 3, then Task 2 gets terminated and task 3 is executed. Task Scheduling Unit takes care of these functions. Inter task communication, Synchronization, Time management is taken care of by RTOS Kernel. Schematic representation of the same is shown in the fig. 5 above.
Where are RTOS (Real Time Operating System) Used?
RTOS finds its application in embedded systems because of its accurate real-time data. Some of the major applications are listed below:
- Mobile applications.
- Online transaction system.
- Medical Critical Care systems.
- Aircraft and defense systems.
- Price quotation systems.
- Network and multimedia systems.
- Anti-Lock brake systems.
- Air traffic control systems.
- Online calling.
- Ticket reservation systems.
- Command control systems.
Advantages of RTOS (Real Time Operating System)
The advantages of Real-Time Operating System include:
- RTOS is event-driven with no processing time delay.
- Real Time OS offers task-based API development. This helps designers or testers to work independently on their parts of the project.
- It reduces the interdependencies between the modules by abstracting timing dependencies and task-based design.
- It offers cleaners and smaller application courses.
- Priority-based scheduling allows the user to separate analytical processing time and Critical processing time.
Disadvantages of RTOS (Real Time Operating System)
The disadvantages of RTOS include:
- RTOS requires specific drivers for faster response time.
- It requires plenty of resources, making it more expensive.
- It uses a complex algorithm, which makes it very difficult to interpret.
- It concentrates only on the accuracy of the program under execution, which increases the waiting time of low priority programs.
- RTOS carries out only the minimum switching of tasks.
- RTOS can only run minimal tasks together.
- It uses plenty of resources, which sometimes are not suitable for the system.
- It concentrates only on applications containing an error.