Concepts of Programming Languages

(Sean Pound) #1
13.6 Ada Support for Concurrency 597

know the name of the task from which it will accept messages. This asymmetry
is in contrast to the design of the language known as CSP, or Communicat-
ing Sequential Processes (Hoare, 1978). In CSP, which also uses the message-
passing model of concurrency, tasks accept messages only from explicitly named
tasks. The disadvantage of this is that libraries of tasks cannot be built for
general use.
The usual graphical method of describing a rendezvous in which task A
sends a message to task B is shown in Figure 13.5.

Tasks are declared in the declaration part of a package, subprogram, or
block. Statically created tasks^2 begin executing at the same time as the state-
ments in the code to which that declarative part is attached. For example, a task
declared in a main program begins execution at the same time as the first state-
ment in the code body of the main program. Task termination, which is a
complex issue, is discussed later in this section.
Tasks may have any number of entries. The order in which the associated
accept clauses appear in the task dictates the order in which messages can be
accepted. If a task has more than one entry point and requires them to be able
to receive messages in any order, the task uses a select statement to enclose
the entries. For example, suppose a task models the activities of a bank teller,
who must serve customers at a walk-up station inside the bank and also serve


  1. Tasks can also be dynamically created, but such tasks are not covered here.


Figure 13.5


Graphical
representation of a
rendezvous caused by a
message sent from task
A to task B


(value)

accept

accept
Free download pdf