Concurrent programming is more difficult and error prone than sequential programming. The concurrent programming features of Ada are designed to make it easier to write and maintain concurrent programs which behave consistently and predictably, and avoid such problems as deadlock and starvation. The language features themselves cannot guarantee that programs have these desirable properties. They must be used with discipline and care, a process supported by the guidelines in this chapter.
The correct usage of Ada concurrency features results in reliable, reusable, and portable software. For example, using tasks to model concurrent activities and using the rendezvous for the required synchronization between cooperating concurrent tasks. Misuse of language features results in software that is unverifiable and difficult to reuse or port. For example, using task priorities or delays to manage synchronization is not portable. It is also important that a reusable component not make assumptions about the order or speed of task execution (i.e., about the compilers tasking implementation).
Avoid assuming that the rules of good sequential program design can be applied, by analogy, to concurrent programs. For example, while multiple returns from subprograms should be discouraged (Guideline 5.6.8), multiple task exits or termination points are often necessary and desirable.
Language Ref Manual references: 9 Tasks
In this chapter...
6.1.2 Anonymous Task Types
6.1.3 Dynamic Tasks
6.1.5 Delay Statements
6.2.1 Efficient Task Communications
6.2.2 Defensive Task Communication
6.2.4 Shared Variables
6.2.5 Tentative Rendezvous Constructs
6.2.6 Communication Complexity
6.3.1 Avoiding Termination
6.3.2 Normal Termination
6.3.3 The Abort Statement
6.3.4 Abnormal Termination