Engineer's Asylum

RTOS vs GPOS (In terms of Task Switching Latency & Interrupt Latency)

Before heading to this tutorial, It’s better to read my previous tutorial about RTOS vs GPOS (In terms of Task Scheduling). If you have already read those, you can continue reading this tutorial.

Switching Latency

In Computing, Latency means “The time that elapses between a stimulus and the response to it”. Task switching latency is defined as the time gap between “A triggering of an event and the time at which the task which takes care of that event is allowed to run on the CPU.

Consider the scenario of a car crash as in the above image. An interrupt occurs at time t1 due to an external signal from the car sensors due to the crash. At time t2 a task wakes up to handle the crash detection. The time between t1 and t2 is called Task switching latency. In the case of RTOS, the task switching latency is deterministic. But that’s not the case in GPOS as the task switching latency varies in a GPOS.

The above plot depicts how latency varies with system load. As the number of tasks that get scheduled increases, the switching latency for GPOS also increases. But that’s not the case in RTOS. In RTOS the latency must always remain constant.

Interrupt Latency

Interrupt latency is the time interval between the time at which an Interrupt occurs and the time at which an ISR starts executing. Let’s say Task-1 was executing and an interrupt occurs at time t1, if it is a higher priority interrupt it will preempt Task-1 and ISR will begin to execute at t2. The time delay between t2 and t1 is the interrupt latency. This time delay is a very important parameter, for example in our airbag application this parameter should be predictable and in terms of nano or microseconds.

In the case of a GPOS, the interrupt latency varies as there is an increase in system load.

When the ISR finishes at t3, the old Task-1 may resume at t4 if its the highest priority else, another higher priority task (For ex: Task 2) may resume. The time delay between the t4 and t3 is the scheduling latency.

Conclusion

Both the interrupt latency and the scheduling latency in RTOS is bounded and kept as minimal as possible. But in the case of GPOS, an increase in system load these parameters may vary significantly.

To be continued…! Stay tuned.

Image Courtesy: BHARATI SOFTWARES

1 Like