Real-Time Systems And Ada Programming Language

Davinder Singh
4 min readOct 2, 2019

--

92N6A radar for Russian S-400 missile system Vitaly V. Kuzmin

In this Article

  • What are real-time systems?
  • Types of real-time systems
  • Time Triggered Vs. Event Triggered Systems
  • Real-time programming languages
  • The Ada programming language
  • Hello World in Ada
  • Conclusion

Summary

A missile is travelling at speed 3 to 4 times the speed of sound. Accelerating towards her target but in between her and her target is a real-time system called The Missile Defense System. This system is tasked with tracking and analyzing the missile before it can begin to perform her attacking maneuver. System has to figure out speed, trajectory and direction of her. And then, perform computations using these parameters to predict where the missile would be after nth second with an impeccable accuracy. After which, it commands the nearest missile battery to launch counter missile targeted towards the incoming missile, only to destroy it in midair. An error of computation or milliseconds (1000th of a second) of latency can result in hundreds of dead bodies. Real-time systems such as the missile defense system, fly-by-wire, factory robots are sometimes the only walls standing between life and death or strategic and economical losses.

What is a real-time system?

Real-time system is a computational system which works in time constrained environment. It guarantees an upper bound over the response time. Usually real-time systems are deployed in fields as controller units, grouped together with sensor network and transducers, for example, computer controlled flow controller, which have flow, temperature and pressure sensor in its sensor network and a stepper motor connected to a valve as a transducer. Its job is to keep the flow through the pipe in the required range. In real-time, it has to figure out the angle to which the valve should be rotated to keep the flow in the range.

A real-time system is a system that is required to react to stimuli from the environment (including passage of physical time) within time interval dictated by the environment. — Brian Randell et al.

Types of real-time systems

Soft real-time systems are those which have liberty of missing few deadlines now and then. But, they still have to keep up with the time and external environment. For example, data acquisition from sensor network, which first has to be sampled before forwarding it to other systems.

Hard real-time systems are those which strictly respect the timely deadlines; Missing a deadline can result in catastrophe. For example, fly-by-wire in combat aircraft; Where delay of a second can turn aircraft into a million pieces.

Time triggered Vs Event triggered

Real-time systems can generally be divided into two categories based on their method of stimuli viz. Time triggered which as the name suggests is periodically triggered for example, system that after every 100 milliseconds check for data from sensors. A router which after every few milliseconds broadcast alive packet to notify other routers that it is working or still alive and Event triggered which stays in hibernation until and unless some specific event occur in the environment; Our flow control system is event based because, whenever flow rate crosses boundary it acts.

Real-time programming languages

Real-time systems are generally compact stand-alone systems working in harsh or remote environments hence, they are implemented with embedded devices i.e microcontrollers. This configuration restricts the range of languages that can be used to program them. Following are requirements of a language used to program for real-time systems

  1. Should be a system programming language (for example C).
  2. Should have support for multi-threading and parallel processing.
  3. Shouldn’t have extra overhead that can cause unneeded delays in the process for example automotive garbage collection.
  4. Should have support for design by contract and program verification.
  5. Should have support for modern constructs such as object-oriented programming paradigm.

In this series we will focus on industry proven Ada programming language for all our discussions.

The Ada programming language

Ada programming language was developed by US Department of Defense to develop projects which are enormous and thus have greater chance to develop bugs. Ada was designed from ground up on the principles of software engineering and has software verifiably and safety built into it. Hence, Ada is perfect for real-time systems because it has been developed keeping them in mind.

Ada is inspired from pascal but contains all features of modern programming languages such as multi-threading, object oriented and generics. It is static in nature like C, C++ etcetera which means that type of every variable is known during compile time; this makes it easy to detect errors at an early stage. Ada is fairly verbose too. You can get free Ada compiler for your system by visiting AdaCore.

Hello World in Ada

Let’s complete the tradition of printing “hello world” and embark on journey of real-time systems.

Conclusion

Real-time systems have great importance in real world. They are everywhere, In satellite, oil platforms, military equipment, combat jets, jumbo jets and whatnot. This is first article in series of articles aimed at explaining ins and outs of real-time systems and Ada programming language. Next we will have a look at scheduling in real-time systems.

Thank you for reading

--

--

Davinder Singh

Davinder Singh a.k.a Dav Vendator is a hobbyist programmer with never ending hunger for knowledge in field of AI, Quantum and Science!