In this Article we are going to answer very basic RTOS related questions that may come in to mind of any new comer in Embedded programming field. for example
- What is RTOS?
- Why to use RTOS?
- How RTOS are different from other general purpose Operating Systems like Windows?
What is RTOS?
RTOS stands for Real Time Operating System. In general, an operating system (OS) is responsible for managing the hardware resources of a computer and hosting applications that run on the computer. Real Time OS does similar work but with very precise timing and a high degree of reliability.This can be especially important in measurement and automation systems where downtime is costly or a program delay could cause a safety hazard.
In general an Operating System performs following tasks
- Memory management
- Task Management
- Time Management
- Context switching
- Inter Task Communication
- Interrupt Handling
Embedded development is less about knowing how to use the OS and more about figuring out how to meet certain constraints such as execution time, memory usage, data coherence and meeting specific deadline. Another important area is peripheral integration or board support which tends to be rather difficult and often requires someone with hardware experience.
Difference Between RTOS and General Purpose Operating System
Fundamentally, the only real difference between an RTOS and a “none” Real Time OS is the fact that the scheduler is deterministic.Other than that the only distinguishing factor is the fact that they tend to be super light weight or striped down to the basic facilities. talking in detail the RTOS and general purpose Operating Systems may also differ in following two constraints
- Setting Priorities: Mainly the Operating Systems run multiple tasks at a time. This multitasking is achieved by giving the CPU to every task for a certain period of time decided by Scheduler. Real Time Operating Systems do this Scheduling on the bases of Priorities of the task. If the higher priority task is running with 100% CPU usage then all other lower priority tasks have to wait for the higher priority task to be finished. RTOS are highly priority bases Systems. On the Other hand, general purpose Operating Systems do not follow the priorities. The main aim of the general purpose OS is to give some amount of CPU to every task. It may be the case that the lower priority task gain the CPU before the high Priority task.
- Interrupt Latency is measured as the amount of time between when a device generates an interrupt and when that device is serviced. General purpose Operating Systems takes very able amount of time to service the Interrupts but the Real Time Operating Systems guaranty that all interrupts will be served with in given maximum amount of time. In other words, Interrupt Latency of Real Time Operating Systems are bounded to some given Time.
Types of Real Time Operating Systems:
There are two basic types of Real Time Operating Systems
- Hard Time RTOS
- Soft Time RTOS
Such Real Time Operating Systems where the Operation/Task time is important factor and the System cannot compromise with time is called a Hard Real Time Operating System. On the other hand such Real Time Operating System where Users can compromise with time constraint are called Soft Real Time Operating Systems. In other words,
An OS that can absolutely guarantee a maximum time for the operations it performs is referred to as hard real-time and In contrast, an OS that can usually perform operations in a certain time is referred to as soft real-time.
To fully grasp these concepts, it is helpful to consider an example. Imagine that you are designing an airbag system for a new model of car. In this case, a small error in timing (causing the airbag to deploy too early or too late) could be catastrophic and cause injury. Therefore, a hard real-time system is needed; you need assurance as the system designer that no single operation will exceed certain timing constraints. On the other hand, if you were to design a mobile phone that received streaming video, it may be OK to lose a small amount of data occasionally even though on average it is important to keep up with the video stream. For this application, a soft real-time operating system may suffice.
One Misconception About RTOS:
one main misconception about RTOS is that they provide better performance then other general purpose Operating Systems. while in real case, RTOS “may” provide better performance in certain case, because of fast execution and less tasks but this is not a rule Actual application performance will depend on CPU speed, memory architecture, program characteristics, and more.
In addition to providing precise timing, real-time computing systems can be set up to run reliably for days, months, or years without stopping. This is important not only for engineers building systems that need 24-7 operation, but also for any application where down time is costly. A “watchdog” feature is also typically included in real-time systems to automatically restart an entire computer in the event that the user program stops running. Furthermore, hardware used in a real-time system is often made very rugged to sustain harsh conditions for long periods.
Do I need Real Time system?
Building a real-time system can be a good idea if you need to make sure that certain parts of your program run in a certain amount of time, or if you need to run your program reliably for long periods of time. If you are working on a mission-critical or safety-related project, then the need for building a real-time system is clear.
Even in the case where precise timing and long term reliability are not absolute requirements for your project, building a real-time system can provide added peace of mind that your program will continue to run without interrupting your measurement or control process. If the system that you are creating could result in maintenance costs in the event it is interrupted, the hardware and software costs required to create a real-time system may be well worth the investment.
Note that a real-time system does not necessarily make sense for every measurement or control project. Real-time operating systems typically only run one program at a time, and most real-time systems do not feature a user interface; in this case a separate computer must be used to provide graphics or user controls. Still, thousands of real-time systems are in operation today and will continue to be a good solution for projects that need precise timing and high reliability.