What is RTOS?
Real-time operating systems (RTOS) are used in environments where a large number of external events must be accepted and processed within certain deadlines. These systems are designed to execute tasks with strict timing requirements, making them ideal for safety-critical applications where failure to meet deadlines could result in serious consequences.
Some examples of these applications include medical devices, automotive systems, aerospace systems,industrial control, telephone switching equipment, and real-time simulations.
Components of Real-Time Operating Systems:

Here, are important Component of RTOS
- The Scheduler: Sets the order of the tasks based on priority.
- Symmetric Multiprocessing (SMP): Handles parallel processing.
- Function Library: Connects kernel and application code.
- Memory Management: Allocates memory to every program, which is crucial for RTOS.
- Fast dispatch latency: Interval between the termination of the task that can be identified by the OS and the actual time taken by the thread, which is in the ready queue, which has started processing.
- User-defined data objects and classes: Use C or C++, which should be prepared according to their operation.
Types of Real-Time Operating Systems:
Three types of RTOS systems are:
**Hard Real-Time:**In Hard RTOS, a given task must start executing at the specified time and must be completed within the allocated time duration.Example: Medical critical care system, Aircraft systems, etc.
**Firm Real-time:**Following the deadlines is a priority. However, missing a deadline may not have a catastrophic impact but could cause undesired effects.Example: Various types of Multimedia applications.
**Soft Real-Time:**Soft Real-time RTOS, accepts some delays by the Operating system. So, deadlines are handled softly by this type of RTOS.Example: Online Transaction system and Livestock price quotation System.
Difference between Super loop and Multitasking?
Super loop:

If you’ve written programs for microcontrollers including Arduino you’re probably familiar with this kind of structure (St.1). When your program starts it performs some setup functions and then it executes your tasks in a round-robin fashion within a while forever loop. These tasks might read from sensors perform some calculations based on those readings and then say display something on a gorgeous led display.
This type of simple programming architecture is known as a super loop. It’s incredibly easy to implement has very little overhead and is great when you only need to accomplish a handful of tasks on your microcontroller.
Multitasking:

The unfortunate thing about this super loop architecture is that you cannot execute tasks concurrently. If task 2 (St.1) starts taking a long time and task 3 (St.1) is your update display task you’ll start to experience some lag. Similarly, if you’re polling for user input like from a serial terminal or reading a sensor you might miss data if other tasks take too long.
To fix that we can use the concept of running multiple tasks at the same time on a multi-core processor. This is actually physically possible. However, since many microcontrollers only have one core the CPU time needs to be split up among the tasks. We can also give higher priority to some tasks so that they happen sooner or take more CPU time for example if we prioritize the user input task users will likely experience less lag but it might mean background tasks take longer to execute.
Terminologies used in Real-Time Operating Systems:
Task: a set of program instructions loaded in memory.
Thread: unit of CPU utilization with its own program counter and stack.
Process: an instance of a computer program.
Usually, a process will have one or more threads used to accomplish tasks threads within a process will often share resources like heap memory and can pass resources to each other. An RTOS is capable of handling only one process but a General Purpose OS (GPOS) can run many processes.
In free RTOS the term task is used to mean something closer to a thread and you’ll often see these terms used interchangeably.
How to choose hardware for running Super loop and Real-Time Operating Systems?

If you’re writing code for a simple 8 or 16-bit microcontroller with 2 kilobytes of ram you’re probably best sticking with the super loop approach. Using the inexpensive controller to run a simple scheduler on such a device the memory and CPU overhead of switching tasks would not leave you with many resources left for your actual program.
People have ported free RTOS to the Arduino Uno. It’s definitely a good way to tinker around with it. As you move into more and more powerful microcontrollers it becomes much more viable to run in RTOS. Then you’ve got clock cycles and memory to spare for things like a scheduler while you can still run a bare metal super loop on something like an esp32. I usually find that the whole reason I bought something with that much computing power is to run several concurrent tasks.
Why would you want an Real-Time Operating System?
There are a number of reasons but the best one that comes to mind is for when you need to do several things concurrently. An esp32 is capable of handling user input reading and writing to an SD card controlling hardware and crunching numbers all at the same time. The big one for something like this is the wireless stack.
These libraries require large amounts of ram and processing power. They also need to respond to events from the network in a short amount of time, which means using an RTOS can be a massive help in this case. It can help you divide up these different features into individual tasks. An RTOS can be great if you’re part of a team working on a larger project.

Hope I will be able to clear some cloud from RTOS for those who are new to RTOS Concept. If you have any questions feel free to ask in the comment and share your thoughts. Share this article with your friends.