Previous Table of Contents Next


Once the rendezvous completes, the select is satisfied and Manager loops back for another cycle. Suppose now that several calls have arrived from different tasks so that at least two of the entry queues have callers pending. In this case, Manager makes an arbitrary selection of one of the queues and then enters a rendezvous with the caller at the head of that queue. This arbitrariness—the algorithm for it is not defined by the Ada standard—makes the selection nondeterministic.

Generally, this nondeterminism is desirable; where it is not, the programmer can use Boolean conditions—so-called guard clauses—on the various accept alternatives to gain more control. For example, a priority selection can be imposed by guarding one of the queues so that it is not selected unless another queue is empty. This guarded command idea was also developed in the laboratory concurrent languages of the 1970s.

The select statement here also has a terminate alternative, which acts as it did in the random-number example. If no calls are pending on any of the entry queues, and if the other tasks are ready to terminate, Manager terminates as well.

It is also possible to set a timer as one of the alternatives, to trigger an action if no other call has occurred within the time-out period. There are other possibilities as well; the select is a “feature-rich” construct.

Ada 95 provides another, complementary, concurrency construct called the protected type. Protected objects have behavior similar to tasks in that mutual exclusion is automatically provided for their operations. However, protected objects are less general than tasks. They were designed not as general-purpose concurrency structures, but rather to support the special case of providing very efficient mutual exclusion on relatively simple objects, for high-performance real-time situations. In these special cases, protected operations can be implemented much more efficiently than general rendezvous-based communication. Space does not permit me to go into more detail on these special structures.

10.4.4.9. Comments on Concurrent Programming

It is a fact that even today, there is no effective, working standard, across operating systems, for processes or threads. Even within the UNIX family, syntactic and semantic differences persist between threads libraries. Given this state of affairs, it is far more efficient and reliable for a small group of compiler experts, working with a well-designed platform-independent model, to tailor a compiler and runtime system to a particular hardware/OS platform than for a large community of application programmers to deal explicitly with OS-specific concurrency constructs in every program.

Ada 83 compilers and runtimes were targeted to dozens of different platforms, from small embedded processors to supercomputers, workstation networks, and personal computers. Ada 95 compilers and runtimes support nearly as many targets already. It is not difficult to write a single concurrent program—with no “conditional compilation” for different platforms—that compiles and executes properly on all available platforms.

Indeed, I developed an interesting implementation of the concurrent-programming classic Dining Philosophers (Feldman, 1992) that compiled and ran—without changing a character of source code—on 26 different compiler/OS combinations, using compilers from 12 different vendors. An Ada 95 version of this program is included in the GNAT examples library; it compiles and runs without change using ObjectAda on Windows and also on the 12 GNAT-supported platforms. The GNAT runtime systems on these platforms support Ada-level concurrency using whatever underlying OS thread support is available or a threads emulator if nothing suitable exists at the OS level.

Concurrent programming is an abstraction method, not just an implementation method for real-time systems. It is often said that the world is concurrent, so modeling the world is best done with concurrent programming. Often, performance of concurrent programs is adequate using straightforward, platform-independent constructs. Programs with real-time performance constraints might require some platform-dependent performance tuning, perhaps with the help of facilities provided by the Ada Real-Time Annex; here the maxim applies that “it is much easier to make a correct program fast than to make a fast program correct.”

As is the case with all newly designed language structures, in immature Ada 83 compilers, the performance of Ada tasking left much to be desired and caused many developers to abandon tasking for more familiar OS-level operations. Over time, however, compilers and runtime systems have reached maturity and performance of Ada-level concurrency compares favorably with platform-specific calls. As the word spreads on this, developers are taking a second look and beginning to realize just how forward-looking the concurrency model was and how effective it can be.

If STEELMAN (HOLWG, 1978) had failed to require concurrency, and the resulting language had therefore failed to support it, the notion of a common language, in which programs could be written with a high degree of platform independence, would have been significantly undermined. The language would have left developers to write precisely the interesting and complex code—the concurrent code—in highly platform-dependent terms. With the current emphasis on multitasking in personal-computer operating systems, and the difficulty many programmers have in coding programs for it, Ada’s higher-level constructs have much to offer.

10.5. Bibliography

This selected bibliography is divided in two sections: Ada Web sites and Ada books, articles, and other publications of interest. A textbook bibliography containing brief reviews, and other reference lists, are available on the Web; where texts have their own associated Web sites, links to these are provided in the various online bibliographies.

10.5.1. World Wide Web Resources on Ada

There are five main sites on the World Wide Web intended for use by those interested in Ada. All these sites mirror, or link to, most of the files on the others, but each site is somewhat different from the others in its emphasis and organizational structure.

ACM Special Interest Group on Ada (SIGAda). The major professional organization for those interested in Ada. This is a membership organization, with very attractive rates for students. http://info.acm.org/sigada

Ada Information Clearinghouse. The “official” U.S. Government-sponsored Ada site. A good place to look for Ada manuals and other documents. Most of this site is copied to the PAL, but this one is less crowded. http://sw-eng.falls-church.va.us

Ada Programming Language Resources for Educators and Students. I maintain this SIGAda-sponsored site that collects the sets of links most useful to educators and students in an easy-to-use fashion. http://www.acm.org/sigada/education

Home of the Brave Ada Programmers. A World Wide Web page for anyone interested in Ada. Contains links to the other Internet sites. http://www.adahome.com

Public Ada Library (PAL). A comprehensive collection of freely available Ada documents, compilers, tutorials, and source code libraries. Nearly everything Ada-related on the Internet is mirrored to this site. http://wuarchive.wustl.edu/languages/ada


Previous Table of Contents Next