# RTOS VS GPOS
When it matters, it runs on RTOS .
RTOS is an acronym for Real Time Operating System. There are such conditions where the correctness or requirement of the output not only depends upon the logic of the application but also time plays an important role for example deployment of airbags while a crash is detected in the vehicles , missile systems where a small error or small time delay may lead to massive destruction . So we need such type of OS to deal with these type of real time Applications .
There are some myths about Real time computing i.e
RTC is fast computing with higher performance But the truth is RTC is predictable computing , timeliness is more important than performance.We can also say an RTOS is supposed to give predictable response.
RTOS deals with guarantees , not with raw speed .having more processor , more RAM ,faster BUS interfaces doesn't make a system real time.
GPOS (General Purpose Operating System)are the OS which we are using for our general work in our daily life for example watching a video ,surfing internet etc etc . Some examples of GPOS are Linux , Mac OS , Windows , Android .
HOW RTOS IS DIFFERENT FROM GPOS.
1 :In terms of scheduling of tasks .
GPOS handles Scheduling of tasks in such a way that it maintains high throughput( Total no of executions per unit time ) , that means sometimes high priority task will get delayed in order to serve 5 or more low priority tasks.That is how GPOS maintains higher throughput . On the other side of the world RTOS execute threads in the order of their priority if a high priority task or thread becomes ready to run it will take over the cpu from any low-priority task that may be executing .
Does it mean that RTOS are very poor in terms of throughput ?
RTOS may yield less throughput than GPOS .A quality RTOS will still deliver decent overall throughput but can sacrifice it for being deterministic or to achieve predictability.
2 :In terms of Latency of switching tasks.
In the computing world , Latency means “ the time elapses b/w a stimulus and the response to it” .Task switching means that time gap b/w a triggering of an event and the time at which the task which takes care of the event is allowed to run on the CPU
Let's take an example in the fig Task1 which detects the crash and Task2 handles the airbags deployment and the time b/w Switching from t1 to t2 ia called Task switching latency
In RTOS task switching latency is finely tuned and time bounded .RTOS always helps you to design such types of systems where this gap must be deterministics or time bounded
But this is not the case in GPOS as this gap increases as time elapses or system load increases .
3 :In terms of interrupt latency
Let an interrupt occurs at time t1 when Task1 is already running the ISR takes the CPU which handles the interrupt because interrupt has higher priority , generally all interrupts have higher priority than any other task , the time b/w switching from Task1 to an ISR is called interrupt latency and after execution of ISR the the high priority task which is ready to execute will take over the CPU or if Task1 resumes .
Interrupt latency should be small as possible in RTOS and almost constant but in the case of GPOS it increases as the system load increases .
Features that a RTOS has but a GPOS doest
-Priority based preemptive scheduling
-No or very short critical section
-Priority inversion avoidance
-Bounded Interrupt latency
-Bounded scheduling latency
For the RTOS achieving predictability or time deterministic nature is more important than throughput , but for the GPOS achieving higher throughput for user convenience is more important .