BOOK REVIEW
Concurrent and Real-Time Programming in Ada by Alan Burns and Andy Wellings. Copyright 2007. Published by Cambridge University Press. ISBN=978-0-521-86697-2.
This book gives the reader a good foundation on how to do concurrent and real-time programming in Ada, while also exploring the new features in Ada 2005. The authors don’t bother to provide an introduction to the language; familiarity with the basic constructs of Ada is a necessary prerequisite. However, on the topic of concurrent programming in Ada the text is exhaustive and authoritative.
Although the book obviously has a strong Ada focus, the authors start with a nice discussion of concurrent programming in general terms. They describe various alternatives for handling concurrency in an balanced, objective way, pointing out that Ada’s approach (which is to offer strong support for concurrency in the language itself) is not the only way to build concurrent systems.
The book is divided into two main sections. In the first part, Ada’s tasking model is described. First presented are the details of how tasks are created, including specifics on task hierarchies and the order in which nested tasks are activated, etc. The authors then give the details of how Ada’s select statement works, including features such as timeouts, termination alternatives, and asynchronous selects. The details of protected objects (basically monitor-like constructs that supports mutually exclusive access to shared data) are also provided. Many examples are given to support the discussion.
The first part ends with a chapter presenting a skeleton library of tasking primitives that use Ada’s object oriented features to good effect. For example, Ada allows you to implement an interface using a task or a protected object rather than an ordinary type. This allows you to treat task related abstractions polymorphically in your program. This seems like a very powerful feature (new with Ada 2005) and I enjoyed seeing it in action.
The second part of the book focuses on Ada’s support for real-time programming. This includes the handling of task priorities and scheduling policies. The authors discuss how to avoid priority inversion by setting “ceiling priorities” on protected objects. Details of Ada’s scheduling algorithm are given, and examples are shown that illustrate how to write programs using advanced scheduling features: dealing with multiple scheduling policies at the same time, handling missed deadlines and execution time overruns, building “execution servers” that support various policies, etc. The authors also describe how Ada handles hardware interrupts and software generated “events,” and how programs can execute periodic tasks effectively.
Ada 2005’s support for real-time programming is extensive, but many of the features it provides are features more typically found in operating systems. This is perfectly reasonable in cases where the Ada run time system is also the operating system—such as when Ada is used for embedded development on the bare metal—but it’s not clear how well these features would work (or if they would even be implementable) on top of some conventional operating system. However, many of the real-time features described in this book are part of the Real-Time Systems annex, an optional part of the Ada standard that would no doubt be ignored in environments where it doesn’t make sense.
The second part of the book ends with a skeleton library of real-time abstractions, following the approach given in the first part of the book. The authors offer both of these libraries as starting points for discussion in the Ada community and clearly hope that they can be evolved into something that might become part of a future Ada standard.
The final chapter of the book is on the Ravenscar profile… a subset of Ada’s tasking features that are easier to implement (and thus can be implemented more efficiently) and easier to analyze (and thus suitable for high integrity programming were correctness is more important than convenience). Although the Ravenscar profile removes quite a few powerful features from Ada’s tasking support, the resulting language is still useful as the authors demonstrate with several examples. I was interested in the fact that Ada provides a standard way for disabling language features. Thus features that are problematic to understand or analyze can be turned off according to local policy to produce a simpler language that is more appropriate for specialized needs. I believe Ada may be unique among programming languages in providing this sort of support in its standard.
In summary “Concurrent and Real-Time Programming in Ada” is a ‘must read’ if you are interested in mastering Ada. Even if your interests are just in the area of concurrent programming, this book would be good to study. Learning how Ada handles this important topic is enlightening no matter what language or approach to concurrency you use.