Book contents
- Frontmatter
- Contents
- Preface
- 1 Introduction
- 2 The nature and uses of concurrent programming
- 3 Inter-process communication
- 4 Task types and objects
- 5 The rendezvous
- 6 The select statement and the rendezvous
- 7 Protected objects and data-oriented communication
- 8 Avoidance synchronisation and the requeue facility
- 9 Exceptions, abort and asynchronous transfer of control
- 10 Object-oriented programming and tasking
- 11 Concurrency utilities
- 12 Tasking and systems programming
- 13 Scheduling real-time systems – fixed priority dispatching
- 14 Scheduling real-time systems – other dispatching facilities
- 15 Timing events and execution-time control
- 16 Real-time utilities
- 17 Restrictions, metrics and the Ravenscar profile
- 18 Conclusion
- References
- Index
7 - Protected objects and data-oriented communication
Published online by Cambridge University Press: 10 December 2009
- Frontmatter
- Contents
- Preface
- 1 Introduction
- 2 The nature and uses of concurrent programming
- 3 Inter-process communication
- 4 Task types and objects
- 5 The rendezvous
- 6 The select statement and the rendezvous
- 7 Protected objects and data-oriented communication
- 8 Avoidance synchronisation and the requeue facility
- 9 Exceptions, abort and asynchronous transfer of control
- 10 Object-oriented programming and tasking
- 11 Concurrency utilities
- 12 Tasking and systems programming
- 13 Scheduling real-time systems – fixed priority dispatching
- 14 Scheduling real-time systems – other dispatching facilities
- 15 Timing events and execution-time control
- 16 Real-time utilities
- 17 Restrictions, metrics and the Ravenscar profile
- 18 Conclusion
- References
- Index
Summary
The problem of sharing resources between processes was briefly discussed in Chapter 3. Two requirements were identified as being essential: mutual exclusion and condition synchronisation. This chapter discusses various ways in which these requirements can be met in Ada without having to encapsulate the resource in a server task and without having to use the rendezvous. Ada gives direct support to protected data by the protected object feature, the discussion of which is the main focus of this chapter. However, the language does also support the notions of atomic and volatile data, which are covered in Section 7.13.
Protected objects
A protected object in Ada encapsulates data items and allows access to them only via protected subprograms or protected entries. The language guarantees that these subprograms and entries will be executed in a manner that ensures that the data is updated under mutual exclusion. Consequently, they are rather like monitors found in previous concurrent programming languages (as described in Chapter 3).
A protected unit may be declared as a type or as a single instance; it has a specification and a body.
- Type
- Chapter
- Information
- Concurrent and Real-Time Programming in Ada , pp. 129 - 162Publisher: Cambridge University PressPrint publication year: 2007