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
4 - Communication and synchronization based on shared objects
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 3 we introduced the task. The tasks in all of the examples in that chapter were independent. They did not share any resources nor did they communicate with each other. As suggested by the cooking examples of Chapter 1, the solution to most parallel problems requires cooperation among tasks. Such cooperation involves communication, mutual exclusion, and synchronization. Communication is the exchange of data or control signals between processes. Mutual exclusion is a mechanism that prevents two processes from simultaneously using the same resource. Synchronization ensures that multiple processes working on a job complete the steps of that job in the correct order. There are two approaches for communication among processes. In this chapter we look at indirect communication via shared objects. In Chapter 5, we'll look at direct communication via Ada's rendezvous mechanism.
Mutual exclusion
Let's start with a simple example that illustrates the need for mutually exclusive access to a resource used by multiple tasks. A small but popular museum has a limited capacity. When that capacity is reached, the sale of tickets must be suspended until space is made available by the departure of some visitors. Recently, the museum has installed turnstiles at each of its four entrances and hired a programmer to write the software to monitor the turnstiles and keep count of the number of visitors currently in the museum.
- Type
- Chapter
- Information
- Building Parallel, Embedded, and Real-Time Applications with Ada , pp. 126 - 165Publisher: Cambridge University PressPrint publication year: 2011