411 REFERENCE · Wikibooks
Ada Programming/Pragmas/Shared
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Pragmas Shared
__TOC__
pragma Shared (local_name);
Summary
Shared is an Ada 83 representation pragma equivalent to Atomic. pragma Shared (was Ada is almost ....)
Robert Dewar
1996-02-17
comp.lang.ada
http://groups.google.es/group/comp.lang.ada/msg/eeee3a7515837ea2
2008-05-28
pragma Atomic is QUITE different from pragma Volatile. pragma Atomic in Ada is essentially identical to pragma Shared in Ada 83. pragma Volatile in Ada is essentially identical to volatile in C, and is a feature that is not available in Ada 83. However, it can only be applied to variables, whereas Atomic can also be used with types.
It was removed from the language in Ada 95 for several reasons:
it was not properly defined Laurent Guerby
Ada 95 Rationale
January
1995
C 5 Shared Variable Control 3
Intermetrics
2008-05-28
The pragma Shared was quite weak. The semantics were only defined in terms of tasks, and not very clearly. This made it inadequate for communication with non-Ada software or hardware devices. Moreover, it could be applied only to a limited set of objects. For example, it could not be applied to a component of an array.
it couldn't be applied to arrays
the name Shared was confusing Annotated Ada 95 Reference Manual
C.6 Shared Variable Control
http://www.adaic.com/standards/95aarm/html/AA-C-6.html#I6739
2008-05-28
Pragma Atomic replaces Ada 83's pragma Shared. The name Shared was confusing, because the pragma was not used to mark variables as shared.
In Ada 95 pragma Shared was replaced by pragma Atomic, Volatile, Atomic_Components, and Volatile_Components.
Portability
Shared is a standard pragma of Ada 83, so it must be implemented by all Ada 83 compilers. It is obsolescent in successive versions of the language, but it is equivalent to pragma Atomic and thus it is usually implemented by Ada 95 compilers for compatibility. GNAT Pro Reference Manual
Implementation Defined Pragmas
http://www.adacore.com/wp-content/files/auto_update/gnat-unw-docs/html/gnat_rm_2.html#SEC91
AdaCore
2008-05-28
This pragma is provided for compatibility with Ada 83. The syntax and semantics are identical to pragma Atomic.
Example
type Device_Status : Status_Register;
Shared (Device_Status);
Incorrect usage
It is usually unsafe to use shared variables for tasking. Ada 83 Quality and Style
Software Productivity Consortium, Inc
7 4 7 Shared Variables and Pragma Shared 07 04
2008-05-28
Do not use shared variables as a task synchronization device. Use pragma Shared only when you are forced to by run time system deficiencies.
See also
Wikibook
Ada Programming
Ada Programming/Ada 83
Ada Programming/Pragmas
Ada Programming/Pragmas/Atomic
Ada Programming/Pragmas/Volatile
Ada Programming/Pragmas/Atomic Components
Ada Programming/Pragmas/Volatile Components
Ada 83 Reference Manual
9 11 Shared Variables
B Predefined Language Pragmas
Ada 95 Rationale
C 5 Shared Variable Control 3
Ada 83 Rationale
13 2 3 Visibility Rules 13 02
Ada 83 Quality and Style Guide
6 2 4 Shared Variables 06 02
7 4 7 Shared Variables and Pragma Shared 07 04
References
Shared
Shared