What is Real-Time Operating System (RTOS) and How It works?

When we hear the word operating system, first in our mind comes that the operating system used in the laptops & computers. Generally, we use different types of operating systems like windows XP, Linux, Ubuntu, Windows 7,8.8.1, and 10. In the smartphones, the operating systems are like KitKat, Jellybean, marshmallow, and Nougat. In a digital electronic device, there is some sort of operating system which is developed by the microcontroller program. There are different types of operating systems to develop for the microcontroller, but here we have discussed the real-time operating system.

What is a Real Time Operating System?

The RTOS is an operating system, it is a brain of the real-time system and its response to inputs immediately. In the RTOS, the task will be completed by the specified time and its responses in a predictable way to unpredictable events. The structure of the RTOS is shown below.

Structure of RTOS
Structure of RTOS

Types of RTOS

There are three different types of RTOS which are following

  • Soft real-time operating system
  • Hard real-time operating system
  • Firm real-time operating system
Types of RTOS
Types of RTOS

Soft Real-Time Operating System

The soft real-time operating system has certain deadlines, may be missed and they will take the action at a time t=0+. The soft real-time operating system is a type of OS and it does not contain constrained to extreme rules. The critical time of this operating system is delayed to some extent. The examples of this operating system are the digital camera, mobile phones and online data etc.

Soft Real Time Operating System
Soft Real-Time Operating System

Hard Real-Time Operating System

This is also a type of OS and it is predicted by a deadline. The predicted deadlines will react at a time t = 0. Some examples of this operating system are air bag control in cars, anti-lock brake, and engine control system etc.

Firm Real-Time Operating System

In the firm real-time, an operating system has certain time constraints, they are not strict and it may cause undesired effects.Examples of this operating system are a visual inspection in industrial automation.

Working with Real-Time Operating System

There are different types of basic functionalities of an RTOS are following

  • Priority based scheduler
  • System clock interrupt routine
  • Deterministic behavior
  • Synchronization and Messaging
  • RTOS service

Priority Based Scheduler

In the priority-based scheduler, most of the RTOS is between 32 and 256 possible priorities for the individual tasks or processes. This scheduler will run the process with the highest priority. If the task is running on the CPU, then the next highest priority task runs and continuous the processes.

In the system, the highest priority process will have the CPU

  • It runs to close
  • If the original task is pre-empted by the new then a high priority process is made ready.

There are three states of the tasks or processes which are like ready to run and the other one is blocked and description of each state is given below.

Ready to Run

The ready to run is said to be when the process has all the resources to run, but it should not be in the running state. Then it is called as a ready to run.


If the task is executing then it is said to have a running state.


In this state, if it doesn’t have the enough resources to run, then it is sent to blocked state.

Three techniques are modified to schedule the task, there are following with their description.

Cooperating Scheduling

In this type of scheduling, the task will run until the execution is completed

Round Robin Scheduling

In this scheduling, each process is assigned a fixed time slot and the process needs to complete its execution or else the task loses its flow and data generation.

Preemptive Scheduling

The preemptive scheduling involves in the priority time-dependent time allocation. In generally 256 priority levels are used and each task has a unique priority level. There are some systems which support the more priority level and multiple tasks have some priorities.

System Clock Interrupt Routine

To perform the time sensitive operation the RTOS will provide some sort of system clocks. If there is a 1ms system clock, then you have to complete the task in 50ms. Usually, there is an API that follows you to say “In 50ms wake me up”. Hence the task would be in sleeping position until the RTOS will wake up. We have two notices that the woken up will not ensure to run exactly at that time, it depends on the priority and if the higher priority is running currently it would be delayed.

Deterministic Behavior

The RTOS moves to great length to protect that whether you have taken 100 tasks or 10 tasks, it does not make any difference in the distance to switch context and it determines the next highest priority task. In the prime area deterministic the RTOS is the interrupt handling, when the interrupt line is signaled them the RTOS immediately takes the action of the correct interrupt service routine and interrupt is handled without any delay.

We have to noise that the developers of the project will write the hardware specific ISR’s. Before now the RTOS gives the ISR’s for the serial ports, system clocks and it may be a networking hardware, but if there is anything specialized like pacemaker signals, actuators, etc., are not be a part of the RTOS.

This is all about the gross generalizations and there is a large variety implementation in the RTOS. Some of the RTOS are operated differently and the above description is capable for the large portion of existing RTOS.

Synchronization and Messaging

The synchronization and messaging provides the communication between the task of one system to another system and the messaging services are following. To synchronize the internal activities the event flag is used and to send the text messages we can use in the mailbox, pipes and message queues. In the common data areas, the semaphores are used.

  • Semaphores
  • Event flags
  • Mailboxes
  • Pipes
  • Message queues

RTOS Service

The most important part of the operating system is the Kernel. To monitor the hardware the task should be relieved and the responsibilities kernel manages & allocate the resources. If the task can’t obtain the CPU attention for every time, then there are some other services provide by the kernel. The following are

  • Time services
  • Interrupt handling services
  • Device management services
  • Memory management services
  • Input-output services

Advantages of RTOS

  • When all the resources and devices are inactive, then the RTOS gives maximum consumption of the system and more output.
  • When a task is performing there is a no chance to get the error because the RTOS is an error free.
  • Memory allocation is the best type to manage in this type of system.
  • In this type of system, the shifting time is very less.
  • Because of the small size of the program, the RTOS is used in the embedded system like transport and others.

In this article, we have discussed how the real-time operating system will work. I hope by reading this you have obtained some basic information. If you have any queries regarding this article or to implement electrical projects, please feel free to comment in the below section. Here is the question for you, what are the functions of the RTOS?

Add Comment