FreeRTOS Lecture 4 – RTOS vs GPOS: Latency

 

RTOS vs GPOS: Latency 

 

 

Difference between a Real-Time Operating System and a General-Purpose Operating System in terms of Task Switching Latency.

In computing, latency means the time that elapses between the stimulus and the response to it.

Task Switching Latency means the time gap between the triggering of an event and the time at which the task, which takes care of that event, is allowed to run on the CPU. 

 

Take an example of this scenario.

Let’s say at t1 an event is triggered or occurred. That could be crash detection, and at t2, a task that handles that crash detection, like the airbag deployment task, is made to run on the CPU. The time gap between t1 and t2 shown in Figure 1 is called a Task Switching Latency.

In the case of RTOS, this latency is always fine-tuned and bounded. The Real-Time Operating System always helps you to design such types of a system where this gap must be deterministic or time bounded. No matter when this event occurs, this gap will always remain almost constant. But this is not the case of a General-Purpose Operating System where this gap varies as time elapses or the system load increases.

RTOS vs GPOS: Latency 
Figure 1. Example for Task Switching Latency.

 

Take a look at the graph shown in Figure 2; as the number of tasks that get scheduled increases, the switching latency for a task increases in the case of a General-Purpose Operating System. But in the case of RTOS, it remains almost constant.

In the case of the General-Purpose Operating System, when more number of threads or processes to schedule, latency will get added up.

RTOS vs GPOS: Latency 
Figure 2. Graph for Task Switching Latency in GPOS vs. RTOS.

 

Differences between RTOS and GPOS in terms of Interrupt Latency:

Interrupt Latency is the time gap between the time at which interrupt triggers and the time at which ISR (Interrupt Service Routine) is started executing on the CPU.

Let’s say task1 is running on CPU, and at time t1 interrupt occurs. If it’s a higher priority, then it will pre-empt this task, and ISR will begin to execute. The Time gap between t1 and t2 shown in Figure 3 is called Interrupt Latency. This Interrupt Latency is an important parameter to service the critical events.

For example, in our airbag deployment application, this gap must be in terms of microseconds or nanoseconds.

The Interrupt Latency is an important characteristic of the RTOS, and the RTOS should have this latency as minimal as possible. In GPOS, this time gap varies as system load increases, and it is unbounded.

When the ISR finishes, it has to make a switch to the high-priority task, which is ready in the system, isn’t it? When ISR finishes at time t3, either old task can resume, which got interrupted due to ISR only if it is the highest priority ready task, or it may switch to some other task which is higher priority at that time. The time gap between the moment at which ISR or task releases the CPU (t3) and the time the new task is switching into the CPU (t4) is called a Scheduling Latency.

In this time gap (time gap between t3 and t4), various activities like saving the context of an old task and retrieving that context of the new task will take place, which we call context switching.

RTOS vs GPOS: Latency 
Figure 3. Example for Interrupt Latency.

 

For a Real-Time Application, this Scheduling Latency must be very narrow. So, the time gap between t3 and t4 must be as small as possible, which is one of the characteristics of the Real-Time Operating System.

To conclude this, both the Scheduling Latency and the Interrupt Latency of the RTOS are bounded, and it won’t increase as the system load increases. But in the GPOS, it is unbounded, and the latency may vary as the system load increases.

In the following article, let’s learn RTOS vs GPOS: Priority inversion.

 

FastBitLab

The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.