[ Table of Contents ] [ Prev ] [ Chapter Overview ] [ Glossary/Index ]
As usual, we begin with some self-test questions. (Answers are listed below in
reverse order.)
Self-Test
Questions
Click Q#-# to see Answer |
Q6-1 |
Can a task be a library unit? |
Q6-2 |
What is the rendezvous mechanism used for? |
Q6-3 |
How many branches can a select statement have a) when it
appears in a calling task, and b) when it appears in a called task? |
Q6-4 |
Where can a terminate alternative appear? |
Q6-5 |
How many kinds of protected operations can appear in a
protected type or protected object declaration? |
Q6-6 |
What distinguishes a protected entry body from a
protected procedure body? |
Q6-7 |
What is the effect of a requeue statement? |
|
Key points of this chapter
- Ada is unusual in that it has multi-tasking capabilities built into the language itself.
- Multi-tasking involves program units called task types, tasks, protected
types, and protected objects. These units are always nested in other units; they are never
library units.
- Tasks and protected objects are objects, and can be either statically declared or
dynamically allocated.
- Task types and tasks export entries. For every entry declared in a task
declaration, there must be at least one accept statement in the task
body.
- Entry call statements have the same form as procedure call statements. Task entries have
the following attributes: 'Count, 'Callable, and 'Terminated. (Count is the number of
calling tasks on an entry queue.)
- The select statement is a compound statement used to provide for the
selection of alternative choices involving a rendezvous between two tasks.
- A task can be terminated using a terminate alternative (in a select
statement) or an abort statement.
- A protected object provides coordinated access to shared data through calls on its
visible protected operations. There are three kinds of protected operations: procedures,
functions, and entries. Every protected entry body has a barrier condition.
- The effect of a requeue statement is to place the calling task at the
end of a different entry queue.
- Partitions, as defined in Annex E, can be used to build single Ada programs that run on
multiple, distributed processors.
Self-Test Answers |
A6-7 |
A requeue statement places the calling
task on a different entry queue. |
A6-6 |
Every protected entry body has a
barrier condition. A procedure body never has a barrier condition. |
A6-5 |
There are three kinds of protected
operations: procedures, functions and entries. |
A6-4 |
A terminate alternative can appear only as the
last alternative of a selective accept statement. |
A6-3 |
A select statement in a calling task can
have only two branches. In a called task a select statement can have any number of
branches. |
A6-2 |
Rendezvous is used to synchronize the actions of
two tasks, and may also be used to transfer data between them. |
A6-1 |
No, task units (and protected units) must
always be nested in other units. |
|
[ Click here to return
to questions ] |
Wrap-up discussion
This chapter has provided an introductory discussion of concurrency and
synchronization, Ada style, along with example programs illustrating relevant language
features and techniques. Key terms included in the Glossary/Index are:
This concludes the final chapter. The appendices contain reference material, mostly
adapted from [ARM95].
[ Back to top of page
] [ Prev ] [ To Appendix A ]