Building Parallel, Embedded, and Real-Time Applications with Ada

Category: Programming
Author: John W. McCormick, Frank Singhoff, Jérôme Hugues
This Month Stack Overflow 2


by pjmlp   2021-02-23
Yep, here some very good books about it, specially relevant given the main subject.

"Building High Integrity Applications with SPARK"

"Building Parallel, Embedded, and Real-Time Applications with Ada"

"Embedded Software Development for Safety-Critical Systems"

by anonymous   2019-07-21

Both yes and no.

What an Ada program needs is its own RTS (Runtime System) - the fairly large chunk of code that (in another recent question) inflates "Hello World" to several hundred kilobytes. This doesn't reflect at all on the "efficiency" or otherwise of Ada, it's a onetime cost regardless of the size of the program, and for any significant program - e.g. involving concurrency - it's competitive with the libraries you'd have to add for other solutions.

The question is - how is that runtime system implemented? If you use the standard off-the-shelf Ada compiler (Gnat) in its standard mode, you get a RTS that layers the Ada concurrency facilities on top of the "pthreads" (Posix threads) package to handle the low level details. And that is obviously layered on top of the OS. Here's a detailed description.

But there are other solutions, where the same facilities can be provided, either using an RTOS, or by the Ada RTS itself on a bare metal CPU, or even not at all (at the expense of no concurrency) if you're targeting an embedded microcontroller with 1K memory.

You can build any Ada program for another RTS by adding the --RTS=path/to/my/rts option to the build command (gnatmake or whatever).

For industrial use, Adacore themselves offer commercial support for VXWorks.

There are examples of RTS for embedded ARM CPUs, layered over FreeRTOS or other RT OSes. (Excellent supporting blog here). These may not provide the full Ada tasking facilities, but a selected subset such as the RAVENSCAR profile, which is amenable to small system implementation (such as 12K or so of ARM Thumb code), and formal proof of correctness (RAVENSPARK).

As these are in part an open source community effort, efforts are fragmented and may not provide all the communication protocols you mention in a comment, however Ada's easy interface to C libraries makes it relatively easy to add Ada wrappers for missing components. And I suspect the community would welcome additional help in covering the remaining bases!

Some protocols are available, but with the rarity of people singing Ada's praises, they aren't widely advertised and may take some digging to find. For example, here's a library that interfaces to the MBUS protocol used by some industrial tools. The same author also offers a preliminary version of a libusb binding.

If you're interested in the mechanism of running Ada with a minimal RTS and no OS underneath, the "Ada Bare Bones" page on the OSDev Wiki may be interesting. This is for i386 but similar "bare bones" RTS exist for AVR and MSP430 microcontrollers.

This book looks like another useful resource, with accompanying tutorial material on its own website.

For a more theoretical treatment, John McCormick's book "Building parallel, real time and embedded applications in Ada" is valuable.

And one more link : as you mention GUI, I'd suggest looking at the Gnoga framework, written in Ada, where your application serves web pages viewable on any browser.

by anonymous   2019-07-21

The "Burns & Welling" book covers concurrency in depth, but doesn't have as much to say about distributed systems as I would expect. Nevertheless it is probably essential reading if you're going to be doing a lot of this stuff.

I'm still reading Professor McCormick's book "Building Parallel, Real-time and embedded Applications with Ada" and it does an excellent job of getting a reader started with a wide range of application-oriented aspects of Ada - sadly missing in other books which focus o the base language - and that includes both the DSA (pure Ada) and PolyOrb (for mixed languages) approaches to distributed systems, including very readable code examples.

Start with this latter book (IMO). (and its lead author has been seen around these parts, so this is a good place to ask questions! :-)

by johnisgood   2019-07-12
I am surprised it does not mention Ada. I really feel like that Ada is not getting enough attention, it definitely deserves more. Even if you have heard of the language before, please do check out some of the resources available, you will not regret it!

It has been supporting multiprocessor, multi-core, and multithreaded architectures for as long as it has been around. It has language constructs to make it really easy to develop, say, embedded parallel and real-time programs. It is such a breeze. I admit I am not quite sure what they are referring to by fearless, but if it means that they can handle concurrent programming safely and efficiently in a language, well, then Ada definitely has it.

Ada is successful in the domain of mission-critical software, which involves air traffic control systems, avionics, medical devices, railways, rockets, satellites, and so on.

Ada is one of the few programming languages to provide high-level operations to control and manipulate the registers and interrupts of input and output devices.

Ada has concurrency types, and its type system integrates concurrency (threading, parallelism) neatly. Protected types for data-based synchronization, and task types for concurrency. They of course can be unified through the use of interface inheritance, and so on.

If you are interested in building such programs, I recommend two books:

...other good resources:

The last PDF will summarize in what ways Ada is awesome for:

- contract-based programming (with static analysis tools (formal verification, etc.))

- object-oriented programming

- concurrent programming

- systems programming

- real-time programming

- developing high-integrity systems

and a lot more. It also gives you a proper introduction to the language's features.

by pjmlp   2017-10-16
I live in Germany, do not always bother to check if the URL contains locale information.

Anyone that actually programmed MS-DOS, knows that we used to program directly against the hardware for actual work. MS-DOS was nothing more than what is usually known as monitor in OS literature.

Continuing the texts from people more relavant to the CS world than me,

"An operating system is a collection of things that don't fit into a language. There shouldn't be one." - Dan Ingalls on

"Project Oberon: The Design Of An Operating System And Compiler" - Niklaus Wirth

And not to let this just be theory, here are a few examples of commercial products using the language runtime to interface with the hardware.