Does Ada real-time need an underlying operating system?

前端 未结 1 1089
一整个雨季
一整个雨季 2021-02-15 15:34

From what I have understood by reading the documentation, the Ada real-time module works completely isolated from the OS. It\'s possible to have concurrency without having an un

相关标签:
1条回答
  • 2021-02-15 16:28

    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.

    0 讨论(0)
提交回复
热议问题