Posts

Showing posts from 2017

An Ada Publish-Subscribe Producer-Consumer Exercise

There are many ways to express the classic producer-consumer problem in Ada. Following is a problem which illustrates some of the interesting features of Ada protected objects. Problem Statement This producer-consumer problem has several requirements: ·          There shall be one producer and many consumers. ·          The number of consumers shall be established at run-time through user input. ·          The producer shall produce a series of random floating point numbers ·          All consumers shall read each number produced by the producer exactly once. ·          The producer shall not know the number of consumers The requirement that the producer shall not know the number of consumers prohibits the use of the Ada Rendezvous mechanism for direct communication betw...

Comparing Ada and High Integrity C++

I have often suspected that use of a safety critical or high integrity coding standard for C++ would yield a level of safety and software reliability approximately equivalent to using Ada with no restrictions. I have documented a comparison of the High Integrity C++ Coding Standard (HIC) produced by PRQA with standard Ada language features. I was mostly correct in my suspicions. There are some rules in the HIC which apply equally well to Ada, such as a prohibition against the use of the goto statement. In many instances the HIC rules require a non-trivial amount of code development and verification, while the Ada solution is trivial. For instance, achieving object initialization in C++ requires the use of carefully implemented constructors, while specifying default initialization for Ada records is relatively trivial. Another example is C++ multi-threading. The HIC lists several rules for the use of locks, mutexes, and condition variables. For Ada, the built-in facilities of task Re...