Book contents
- Frontmatter
- Contents
- List of illustrations
- List of tables
- Foreword
- Preface
- 1 Introduction and overview
- 2 Sequential programming with Ada
- 3 Task basics
- 4 Communication and synchronization based on shared objects
- 5 Communication and synchronization based on direct interaction
- 6 Distributed systems with Ada
- 7 Real-time systems and scheduling concepts
- 8 Real-time programming with Ada
- 9 Tools for building and verifying real-time applications
- References
- Index
3 - Task basics
Published online by Cambridge University Press: 01 June 2011
- Frontmatter
- Contents
- List of illustrations
- List of tables
- Foreword
- Preface
- 1 Introduction and overview
- 2 Sequential programming with Ada
- 3 Task basics
- 4 Communication and synchronization based on shared objects
- 5 Communication and synchronization based on direct interaction
- 6 Distributed systems with Ada
- 7 Real-time systems and scheduling concepts
- 8 Real-time programming with Ada
- 9 Tools for building and verifying real-time applications
- References
- Index
Summary
In Chapter 1 we demonstrated the effectiveness of concurrent algorithms. Together, Horace and Mildred can prepare a meal faster than one of them alone. The concurrent algorithm for controlling the process of chutney cooking provides a simpler and more reusable solution than the original sequential algorithm. Now that you have a basic understanding of sequential programming with Ada we are ready to create concurrent Ada programs.
Ada is a concurrent programming language — it provides the constructs needed to support the creation of programs with multiple threads of control. Ada's task is an implementation of Dijkstra's (1968) process. An Ada program is composed of one or more tasks that execute concurrently to solve a problem. In this chapter we examine the Ada task as an independent entity. In the next two chapters, we'll examine the facilities that allow tasks to communicate, synchronize, and share resources.
Defining tasks
As with packages, the definition of a task has two parts: a declaration and a body. We can define a task type from which we can create multiple tasks that execute the same sequence of statements. Alternatively, we can define a singleton task that ensures that only one task executes the sequence of statements in the body. Let's look at a program that illustrates both alternatives.
- Type
- Chapter
- Information
- Building Parallel, Embedded, and Real-Time Applications with Ada , pp. 107 - 125Publisher: Cambridge University PressPrint publication year: 2011