Suppose a person is driving a car on a highway at a speed of 70 miles per hour. Now, somehow the car meets with an accident. Fortunately the airbag deployed at the right time and saved the life of the driver.
So, we see that airbag is a very good feature in a car which can save a life someday. But, did we think what would have happened if the airbag would have deployed a few seconds late? Yes, we would have lost a life. So just imagine the dependency on the accuracy of opening of the airbag.
So, what makes that airbag deploy at the right time? Well, welcome to the world of RTOS.
RTOS stands for Real time operating systems.
In modern times we have seen an evolution of embedded systems. Nowadays embedded systems can be found all around us. Be it on cellphones, air conditioners, digital homes, cars etc. Little we realize their contribution in making our life comfortable and safe. Safety is one aspect in which we are now depending more and more on these computerized embedded systems. The heart of these systems is the OS they use. Most of these systems use RTOS.
What is an RTOS?
As the name suggests, there is a deadline associated with tasks and an RTOS adheres to this deadline as missing a deadline can cause affects ranging from undesired to catastrophic. The example we discussed in the beginning of this article is an example of catastrophic affect of an RTOS missing a deadline.
As discussed above that the embedded systems are becoming more and more complex today and with each passing generation their intrusion in our daily lives will become deeper. This means they will bear more and more responsibilities on their shoulders to solve real time problems to make our life easier. But, this requires more and more complex real time applications that RTOS will have to manage effectively.
Some of the most widely used RTOS are :
- Windows CE
Classification of RTOS
RTOS can be classified into three types :
- Hard RTOS : These type of RTOS strictly adhere to the deadline associated with the tasks. Missing on a deadline can have catastrophic affects. The air-bag example we discussed in the beginning of this article is example of a hard RTOS as missing a deadline there could cause a life.
- Firm RTOS : These type of RTOS are also required to adhere to the deadlines because missing a deadline may not cause a catastrophic affect but could cause undesired affects, like a huge reduction in quality of a product which is highly undesired.
- Soft RTOS : In these type of RTOS, missing a deadline is acceptable. For example On-line Databases.
Features of RTOS
An RTOS must be designed in a way that it should strike a balance between supporting a rich feature set for development and deployment of real time applications and not compromising on the deadlines and predictability.
The following points describe the features of an RTOS (Note that this list is not exhaustive) :
- Context switching latency should be short. This means that the time taken while saving the context of current task and then switching over to another task should be short.
- The time taken between executing the last instruction of an interrupted task and executing the first instruction of interrupt handler should be predictable and short. This is also known as interrupt latency.
- Similarly the time taken between executing the last instruction of the interrupt handler and executing the next task should also be short and predictable. This is also known as interrupt dispatch latency.
- Reliable and time bound inter process mechanisms should be in place for processes to communicate with each other in a timely manner.
- An RTOS should have support for multitasking and task preemption. Preemption means to switch from a currently executing task to a high priority task ready and waiting to be executed.
- Real time Operating systems but support kernel preemption where-in a process in kernel can be preempted by some other process.
Some Misconceptions related to RTOS
- RTOS should be fast. This is not true. An RTOS should have a deterministic behavior in terms of deadlines but its not true that the processing speed of an RTOS is fast. This ability of responsiveness of an RTOS does not mean that they are fast.
- All RTOS are same. As already discussed we have three types of RTOS (Hard, firm and soft).
- RTOS cause considerable amount of CPU overhead. Well, again this is not true. Only 1%-4% of CPU time is required by an RTOS.
In the future article of the RTOS series, we will discuss in detail about the architecture of an RTOS.