Real-Time Processing: How It Works

Introduction

A realtime processing systems ensure the execution time can be completed within certain interval with minimal variability. This is important because from time crtical systems such as a audio playback, if the processor does not feed the audio driver with ontime data, the user will experience sudden audio cracking and interruptions affecting user experiences, which can separate winner from low quality products.

Background:

Realtime system requires low software overhead and ensure that the execution time is deterministic. This dictates that both embedded os and the hardware microtechture needs to complie to this.

Real-time systems are often implemented on microcontrollers with RTOS (real-time operating systems). RTOSes provide a number of features that make them well-suited for real-time applications, such as:

One can also implementing a realtime processing such as audio on a general purposed SoC by configuring the operating system task schedulers with right priority settings.

Example:

Real-Time Audio Playback on RTOS using MicroController

A real-time system is one that must guarantee that certain tasks are completed within a specific time interval. Audio playback is an example of a real-time system, as the audio data must be played back at a constant rate to avoid choppy or distorted sound.

One way to implement real-time audio playback on a microcontroller with RTOS is to use the RTOS to schedule the audio playback task to be executed at a specific interval. The RTOS can also handle interrupts from the audio device, so that the audio playback task is not interrupted by unexpected events.

Real-Time Execution on General Purpose CPUs

General purpose CPUs can be used for a variety of tasks, including real-time audio playback. However, in order to ensure that real-time data is processed within a specific time interval, the OS task scheduler must be able to distinguish realtime data from other background program activities.

This is achieved by increasing the affinity (i.e. level of importance) of the real-time execution thread. For example, the audio playback thread in the audio OS framework can be set to the highest affinity, so that it is guaranteed to be executed on time.

However, it is important to note that CPUs have limited resources, so not all tasks can be given the highest affinity. If too many tasks are given high affinity, the CPU may not be able to execute all of them, which can lead to poor user experience.

Detailed Breakdown of two types of realtime systems

Microcontroller with RTOS is an audio playback system.

The audio playback system must ensure that the audio data is played back at a constant rate.

This is achieved by using the RTOS to schedule the audio playback task to be executed at a specific interval.

The RTOS also handles interrupts from the audio device, so that the audio playback task is not interrupted by unexpected events.

Realtime Excustion on general purpose CPU such as ARM A class SoC:

The OS task scheduler must be able to distinguish realtime data vs other background program activities.

This is achieved by increasing the affinity (i.e. level of importance) of the real-time execution thread.

For example, setting audio playback thread in the audio OS framework to the highest.

However, one thing to notice, that all CPU has limited resources, so one cannot set all tasks to be high affinity, or else the operating system and all its program will stall inducing poor user experience.

How to Design a Real-Time Processing Device

There are a few key things to consider when designing a real-time processing device:

Summary

Real-time audio playback is an important application that requires careful design and implementation. By using the RTOS to schedule the audio playback task and handle interrupts from the audio device, it is possible to ensure that the audio data is played back at a constant rate and meets the timing requirements of the application.

Conclusion

Real-time processing systems are used in a wide variety of applications, including audio playback, video streaming, and control systems. The design of a real-time processing system must take into account the specific requirements of the application, the available hardware resources, and the timing requirements.

Further Reading: