Real Time Programming: Myths and Reality

Real Time Programming: Myths and Reality

The term “real time” has become a buzzword, as in “real time stock quotes” or “real time database queries”. However, neither a database-oriented system nor a NYSE stock ticker running on your desktop is truly a real time application. As opposed to a common belief, “real time” doesn’t mean “fast response time” or “low latency”; rather, it means, among other things, a totally deterministic operation mode.

For example, if you execute the same database query twice, each time it will take a different amount of time to execute, depending on various extraneous factors such as the number of users currently connected to the database, system load, the distance of the disk sector that contains the database records from the read/write magnetic head, the size of available memory etc. In other words, the response time of a database query is not deterministic, and hence it’s not a real time operation.

On the other hand, a cellular phone must operate in real time mode: the chipset that receives the airborne digital signals must demodulate, filter, and correct these signals within a fixed amount of time, every time. Not some of the time, or most of the time, but every time. Note that even a millisecond delay is unacceptable in this case: the digital signals keep coming in. If they are not processed on their allotted time slice, they are simply overrun by more incoming signals (think of a Web-based media player that skips frames when displaying a video clip). To conclude, real time essentially means a totally deterministic performance all the time, regardless of extraneous factors such as the number of users, available free memory etc.

See also  How to Create and Deploy QR Codes Online: A Comprehensive Guide

Many programming languages are unsuitable for real time programming due to their non-deterministic nature. For example, languages that have a built-in garbage collector are very problematic because the garbage collector might “wake up” at the wrong moment, halting all other operations until it finishes. A real time software application that controls the amount of fuel supplied to an airplane’s engine at lift off cannot be interrupted by a garbage collector, not even momentarily.

The designers of C++ deliberately refrained from adding to it features that would disqualify it from being used in real time applications. Indeed, not every feature in C++ is deterministic: dynamic memory allocation is not a deterministic operation because extraneous factors such as heap fragmentation affect its performance. Operator dynamic_cast is not deterministic either. However, unlike other languages, C++ doesn’t force these features on you (see also, so if your application must operate in real time mode, you can avoid such features, thereby ensuring a deterministic operation.


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist